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
When plotting with drawstyle='steps' (or steps-pre, steps-mid, or steps-post) there is a graphic display error. This was submitted to Pandas (pandas-dev/pandas#31965) but I realize it may be a Matplotlib issue.
Specifically, on the graphic below and when using these two vectors:
x = [0,1,2]
y = [0,1,2]
steps-pre and steps imply that the y values is 1 in x=[0,1]. I would argue that the proper way to interpret this data is that y = 0 at x = 0, and presumably remains at 0 until the y value is updated to 1 at x=1. These two options essentially drop the first data point. There is some indication of an (x,y) = (0,0), but it is minimal.
steps-post has the same issue but at the end.
steps-mid graphically weights the values unevenly. The y=1 value has twice the weight of the other two line segments, based on length.
The fifth panel is graphically correct in my opinion, but requires a modification of the data before plotting it.
That's definitely not a display error. That is, the step demo shows what we would expect.
I can see how adding an extra line-segment at the beginning or end might be useful in some applications, however, we do in general not know how long that line should be. Consider e.g. x = [1.1, 1.7, 2.1]; y = [0,1,2]; what would in that case the expected output look like?
@mankoff Thanks for the report. Unfortunately, steps is not designed to what you‘ve described in your expectation. As indicated, it‘s also not trivial, to generalize this to non-uniform distances.
This has been discussed extensively in #15019, #15065 and the links therein. You are welcome to join the discussion in the latter. I‘m going to close this to keep this topic in one place.
Bug report
Bug summary
When plotting with
drawstyle='steps'
(orsteps-pre
,steps-mid
, orsteps-post
) there is a graphic display error. This was submitted to Pandas (pandas-dev/pandas#31965) but I realize it may be a Matplotlib issue.Specifically, on the graphic below and when using these two vectors:
steps-pre
andsteps
imply that they
values is 1 inx=[0,1]
. I would argue that the proper way to interpret this data is that y = 0 at x = 0, and presumably remains at 0 until the y value is updated to 1 at x=1. These two options essentially drop the first data point. There is some indication of an (x,y) = (0,0), but it is minimal.steps-post
has the same issue but at the end.steps-mid
graphically weights the values unevenly. They=1
value has twice the weight of the other two line segments, based on length.Code for reproduction
Actual outcome
Expected outcome
See bottom panel.
The plot should display y[0] from x[0] to x[1], y[n] from x[n] to x[n+1], and therefore needs to have an x[n+1] appended to the end of the plot.
The text was updated successfully, but these errors were encountered: