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
{{ message }}
Repository navigation
[ENH]: Switch text wrapping boundary to subfigure #28378
I'm confused why this doesn't already work, since Text.get_figure() currently returns the parent figure rather than the root.
In [11]: fig=plt.figure()
In [12]: sfig=fig.subfigures()
In [13]: ax=sfig.subplots()
In [14]: txt=ax.text(0, 0, "foo")
In [15]: txtOut[15]: Text(0, 0, 'foo')
In [16]: txt.get_figure()
Out[16]: <matplotlib.figure.SubFigureat0x7f2eff1b6ed0>
I have just checked that the code in #28358 (comment) does not wrap - assuming it was due to the root figure, but it may well be that there is a calculation issue instead.
fig=plt.figure()
sfig1, sfig2=fig.subfigures(ncols=2)
ax1, ax2=sfig2.subplots(nrows=2)
ax2.set_title("Another title that won't fit in this amount of space", wrap=True)
sfig2.suptitle("Long title that won't fit in this amount of space", wrap=True)
plt.show()
I can confirm both that tick labels wrap incorrectly and titles wrap correctly and that the tick labels have the correct (sub) figure attached to them.
Activity
rcomer commentedon Jun 12, 2024
I'm confused why this doesn't already work, since
Text.get_figure()currently returns the parent figure rather than the root.rcomer commentedon Jun 12, 2024
Should
figure_boxbe involved in this line?matplotlib/lib/matplotlib/text.py
Line 665 in 14a04a0
Edit: and some of the lines above it. I guess when this was written
figure_box.x0andfigure_box.y0were always zero so didn't need accounting for.timhoffm commentedon Jun 12, 2024
I have just checked that the code in #28358 (comment) does not wrap - assuming it was due to the root figure, but it may well be that there is a calculation issue instead.
rcomer commentedon Jun 12, 2024
Titles do not have a wrapping problem... 😕
tacaswell commentedon Jun 14, 2024
I can confirm both that tick labels wrap incorrectly and titles wrap correctly and that the tick labels have the correct (sub) figure attached to them.
Very odd.
FIX: Fix text wrapping
FIX: Fix text wrapping
FIX: Fix text wrapping