-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Labels don't get wrapped when set_yticks() is used in subplots #28358
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
Comments
Thanks for the clear report @soogui. I confirm that I have reproduced this with our |
I'm not clear what the correct behaviour is here though. Currently it's wrapping on the edge of the figure. What would the inner axes wrap on? The axes to the left presumably, but that isn't conceptually straight forward as an axes knows about its figure but not about its neighbours, and it knows its own spine position but doesn't try to reserve space for itself outside those spines. Note we usually do the opposite and make the axes further apart to accommodate the ytick labels. |
For the current architecture, this is the expected behavior. We should better document what I see two possible ways to improve:
|
I think the conceptually simplest is to not allow auto wrap for tick labels. Folks can manually wrap if they need to. |
Well, the case of one subplot with long tick labels works. IMHO we should not break that. Just documenting that wrapping is limited to the figure boundary is good enough to manage expectations on the current behavior. |
Closes matplotlib#28358 by documenting the effect of wrap.
@jklymak When #28177 is in, we could switch the wrapping box (in
--> Created a separate issue for this #28378. |
That's likely fine. However it should be noted that even in the single subplot situation the wrap is incompatible with layout management since that adjusts the size of the axes to account for the size of the labels versus wrapping the labels. As stated I am mildly opposed to us jumping through hoops to allow wrapping tick labels because I don't think it s a generally useful thing to do. However if the issues with wrapping tick labels also extends to other text boxes in subfigures, that might merit some effort to fix. |
`_get_dist_to_box()` assumed that the figure box (x0, y0) coordinates are 0, which was correct at the time of writing, but does not hold anymore since the introduction of subfigures. Closes matplotlib#28378 Closes matplotlib#28358
`_get_dist_to_box()` assumed that the figure box (x0, y0) coordinates are 0, which was correct at the time of writing, but does not hold anymore since the introduction of subfigures. Closes matplotlib#28378 Closes matplotlib#28358
When #28401 is in, one can write the original plot using subfigures:
|
`_get_dist_to_box()` assumed that the figure box (x0, y0) coordinates are 0, which was correct at the time of writing, but does not hold anymore since the introduction of subfigures. Closes matplotlib#28378 Closes matplotlib#28358
Uh oh!
There was an error while loading. Please reload this page.
Bug summary
When plotting bar charts in subplots with very long labels, the option of wrapping text only works on the first plotted subplot, despite passing
wrap=True
toset_yticks()
in both cases.Code for reproduction
Actual outcome
Expected outcome
The label text on the y axis should appear wrapped on both subplots
Additional information
No response
Operating system
macOS 14.4 (23E214)
Matplotlib Version
3.8.3
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
Python 3.11.8
Jupyter version
4.2.0
Installation
pip
The text was updated successfully, but these errors were encountered: