How can I give the extents for a text in Matplotlib, while still wrapping it if needed?
I can make the text wrap at extent of the whole figure like this:
fig.text(x, y,
"Hello, I'm a quite long text in a quite small figure, and I will probably be wrapped somewhere along the way!",
wrap=True)
And I can use clip_box
to clip the text like this:
fig.text(x, y,
"Hello, I'm a quite long text. Much of me will be clipped off, when I reach past max_width",
wrap=True,
clip_box=Bbox([[x, y], [max_width, max_height]]) )
But I would like to be able to set the width at which to wrap the text. Is that possible?
edit: as @tom points our in the comments, the behavior here is hardcoded: https://github.com/matplotlib/matplotlib/blob/65158f9351ffdb2f9b77ac98277592b58c28ee2a/lib/matplotlib/text.py#L600
Any suggestions for a workaround are very welcome!