-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Layout managers have problems with titles containing MathText #11468
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
Thats because we have no way of knowing the text size other than by the fontsize. If we stick a huge symbol like |
Sure? If only fontsize matters, how do you find out the difference between "iiiiiiiiiii" and "mmmmmmmmmm", which clearly is accounted for, e.g. in the case of ylabels. Here are the boxes for the text obtained via tight_layout constrained_layout Seeing this it might be understandable that the multiline with mathtext (middle column) is cut on top. But what is really strange is that in the case of the single line (right column), the bounding box is actually correct, but still overlaps with the axes. So in total those might be two different issues:
|
OK, the last column the problem is that neither layout manager cares if the title overlaps the axes. Thats the fault of where the title is being placed. If you call w/ no layout manager the i still overlaps. The way the layout managers work is by adjusting the size of the axes assuming a border that takes up the other decorators; here the layout managers are doing the right thing from their point of view. If we wanted something that does a better job of positioning axes that could be done separately. The middle column is definitely just a problem with the bbox from multiline w/ text. Multi lines are hard: #9775 |
Hmmm, though #9498 should have taken care of the right hand column case. I'll need to see whats going on there. |
Ah... #9498 only does its thing if the xaxis is on top. An easy fix is to also move the title if it overlaps the actual axes. My only concern there is performance because I think the axes tightbbox calf can be expensive. |
OK, not finding a nice consistent way to do this. OTOH, note that there is a pad argument now for |
@ImportanceOfBeingErnest please see #11499 and #11502. I think together they solve the issue here... |
Yep, it seems so. Once they are merged, this can be closed. |
Layout managers seem to have problems with titles containing MathText.
One would expect to have a title which neither overlaps with the axes nor with the figure boundary in all cases depicted below.
tight_layout
multi line title
as expected
multi line title with MathText
The title is a bit squeezed towards the top figure boundary, but does not go beyond it, nor does it overlap the axes. This is somehow still acceptable.
single line title with MathText
Here the title overlaps with the axes. This is in thus far strange because in the case above with multiple lines, this overlap does not occur.
constrained_layout
multi line title
as expected
multi line title with MathText
The title exits the figure. This is not desiredeable.
single line title with MathText
Here the title overlaps with the axes.
code
Matplotlib version
The text was updated successfully, but these errors were encountered: