You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was asked a long time ago, and I just ran into a similar need. It would be nice to be able to easily make a filled step plot. The solutions I've come up with are suboptimal.
This sounds like a bug to me, as Eric says in the mailing list:
The Line2D object should not be modifying the
coordinates it is given. At the very least, its get_path() should
return the actual path it is drawing; at present it does not.
I tried to solve this issue, but there some small refactoring in Lines2D is necessary:
self._path is set by recache(). The path drawn for step-lines is only calculated when drawing.
The easiest solution seems to be to move the calculation from "real" path to recache.
Because i am not sure about side effects, i need some input from more experienced
developers? @efiring@mdboom@dmcdougall
Also while studying the code, i found the following lines:
A easier solution would be to just add a get_drawn_path method, which returns "real" path (and if necessary calculates it). The step-calculation function would be shared with the draw methods.
We fixed this as part of a group assignment on my CS course. We did a bit of refactoring in Line2D and made get_ydata and get_xdata return the actual drawn data (when orig=False). Filled step plots are then as easy as:
@Tillsten: I'm not sure what the side effects you're suggesting would be -- it probably depends on what ways users are relying on the way it works now -- but maybe as a start we could do that refactor and run it against the test suite...
Activity
lebek commentedon Mar 30, 2013
This sounds like a bug to me, as Eric says in the mailing list:
lebek commentedon Mar 30, 2013
Also see #643, especially the fix proposed by @ycopin.
Tillsten commentedon Mar 31, 2013
I tried to solve this issue, but there some small refactoring in Lines2D is necessary:
self._path is set by recache(). The path drawn for step-lines is only calculated when drawing.
The easiest solution seems to be to move the calculation from "real" path to recache.
Because i am not sure about side effects, i need some input from more experienced
developers? @efiring @mdboom @dmcdougall
Also while studying the code, i found the following lines:
Are the last two lines not redundant? (But i don't know matplotlib interals good enough to be sure.)
Tillsten commentedon Mar 31, 2013
A easier solution would be to just add a get_drawn_path method, which returns "real" path (and if necessary calculates it). The step-calculation function would be shared with the draw methods.
lebek commentedon Apr 1, 2013
We fixed this as part of a group assignment on my CS course. We did a bit of refactoring in Line2D and made get_ydata and get_xdata return the actual drawn data (when
orig=False). Filled step plots are then as easy as:To make things more convenient we added a
fillkwarg to plt.plot and plt.step:Not sure if either change would be desirable upstream but I'll try to put together a PR.
mdboom commentedon Apr 1, 2013
@Tillsten: Those lines are not redundant. The first performs the non-affine part of the transform, the second performs the affine part.
mdboom commentedon Apr 1, 2013
@Tillsten: I'm not sure what the side effects you're suggesting would be -- it probably depends on what ways users are relying on the way it works now -- but maybe as a start we could do that refactor and run it against the test suite...
parrenin commentedon Aug 16, 2013
An additionnal request is to have an equivalent of 'fill_between' for step.
tacaswell commentedon May 15, 2015
Closing as duplicate of #643
ENH : add step_where kwarg to fill_between{x}
ENH : add step_where kwarg to fill_between{x}
ENH : add step_where kwarg to fill_between{x}
ENH : add step_where kwarg to fill_between{x}