-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
-
Star 19.5k
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
Boxplot: Median line too long after changing linewidth #19409
Boxplot: Median line too long after changing linewidth #19409
Comments
anntzer
commented
Jan 31, 2021
•
edited
edited
I agree with changing the capstyle. As for the overlap at the edges, likely it's a zorder issue? #18216/ #17247 likely matter too. |
ghost
commented
Jan 31, 2021
•
edited by ghost
edited by ghost
Just another note: The mean (as opposed to median lines) do not seem to have the same issue: data = [[1, 2, 3, 4, 7]]
fig, ax = plt.subplots()
ax.boxplot(data,
showmeans=True,
meanline=True,
meanprops={"linewidth": 8}) gives me Edit: The mean line still overlaps the bounding box, but at least does not extend beyond it. |
ghost
commented
Jan 31, 2021
A symptomatic workaround for the overlapping issue would be to change zdelta = 0.1 in this line to zdelta = - 0.1 That resolves it for me. As far as I can see, |
tacaswell
commented
Jan 31, 2021
There are different cap styles for solid lines and dashed lines. This is also a case where the re-scaling of the dash pattern with linewidth is not an improvement... |
oscargus
commented
Jun 4, 2022
Zooming in gives that the zorder for the mean line indeed should be changed as well (as it is clear that there are different cap styles).
|
oscargus
commented
Jun 4, 2022
Should be a first good issue: change the default cap style and the zorder. Problems may involve testing. |
wmandla
commented
Jun 23, 2022
•
edited
edited
I would like to make a small contribution in order to fix this issue. The solution has already been hinted above. This would be my first contribution and I am not quite clear on what is expected when testing the fix. |
kidkoder432
commented
Aug 7, 2023
Where are these defined? Maybe changing the default cap style would help. |
kidkoder432
commented
Aug 7, 2023
Nevermind, found it in |
Closes #19409.
- Set the default capstyles (solid and dashed) for median and mean lines in boxplots to "butt".
I also modieifed the behaviror for setting the capstyle for median lines to obey the user's preference
instead of overriding it.
- The boxplot PDFs were using the wrong capstyle, so I modified the references to use the butt captyle.
- Fixed a small typo in `bxp()`
- Added a new test for the median line (from PR #23335)
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Backport PR matplotlib#26462 : Boxplot fix median line extending past …
4ffe411
…box boundaries matplotlib#19409
…462-on-v3.8.x Backport PR #26462 on branch v3.8.x (Boxplot fix median line extending past box boundaries #19409)
When changing the
linewidth
property of the median line in boxplots, the line will extend beyond the box width.For example,
gives (on Matplotlib 3.2.2):
By simply chaning the
solid_capstyle
propery to"butt"
inI was able to improve this a bit (I stole that trick from here):
Ideally, one could now reduce the median line length such that it no longer overlaps with the black bounding line of the box.
Since the box line width is only accessible in "points" units, it would need to be transformed to data units.
I was unable to get this to work, though.
Would it be possible/desirable to change the default setting for
solid_capstyle
?Could this be handled in a different way?
The text was updated successfully, but these errors were encountered: