-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix stepfilled histogram polygon bottom perimeter #15783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix stepfilled histogram polygon bottom perimeter #15783
Conversation
Thanks for the PR. |
Yes, that's a good point, sure. Would you recommend
|
It should be possible to do this without image comparison test (which are expensive memory- and maintainance-wise) by comparing the returned patch (or its vertices) to the expected coordinates. |
a3a238f
to
e0854bd
Compare
I've added a couple of test cases for different combinations of
fail on master and succeed after this fix. There was already an image comparison test to check the outline when bottom is given, |
e0854bd
to
0786768
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, you could also do without the blank lines in the first four examples. They are short and clear enough.
The polygon generated by hist() when histtype='stepfilled' and bottom is not None contained an invalid starting point with a y-value of zero resulting in a diagonal line at the bottom of the first bin. This commit fixes the computation of the starting point and thus removes the drawing artifacts from the first bin.
0786768
to
f40b0f8
Compare
Thanks! |
PR Summary
The polygon generated by
hist()
whenhisttype='stepfilled'
andbottom
is not None contains an invalid starting point with a y-value of zero resulting in a diagonal line at the bottom of the first bin. This PR fixes the computation of the starting point and thus removes the drawing artifacts from the first bin.Closes #15782.
Details
The y-values of the polygon perimeter are initialized with zeros. The number of points is such that the start (
0
) and endpoint (8
) can/should be identical. The index assignment of the points is as indicated in the following sketch:The endpoint (
8
) is set to the given bottom value.The first point (
0
) is not modified in subsequent code unlessstacked
is True. (In that case, the starting point (0
) is made equal to the next point (1
) before assigning the new top outline.) In our case, this means the starting point (0
) is still at zero.Finally, in the case of
stepfilled
, the endpoint (8
) (with the correct y-value) is truncated. (In the case ofstep
the whole lower edge is truncated, as it should be since it's not closed.)This PR assigns the y-value of the endpoint (
8
or-1
in general) to the staring point (0
) for every polygon. This works regardless ofstacked=True/False
andstep/stepfilled
.PR Checklist