Auto-wrap text
Matplotlib can wrap text automatically, but if it's too long, the text will
still be displayed slightly outside the boundaries of the axis.
Note: Auto-wrapping does not work together with
savefig(..., bbox_inches='tight'). The 'tight' setting rescales the canvas
to accommodate all content and happens before wrapping. This affects
%matplotlib inline in IPython and Jupyter notebooks where the inline
setting uses bbox_inches='tight' by default when saving the image to
embed.

import matplotlib.pyplot as plt
fig
=
()
((
0
,
10
,
0
,
10
))
=
(
"This is a really long string that I'd rather have wrapped so that it "
"doesn't go outside of the figure, but if it's long enough it will go "
"off the top or bottom!"
)
(
4
,
1
,
,
ha
=
'left'
,
rotation
=
15
,
wrap
=
True
)
(
6
,
5
,
,
ha
=
'left'
,
rotation
=
15
,
wrap
=
True
)
(
5
,
5
,
,
ha
=
'right'
,
rotation
=-
15
,
wrap
=
True
)
(
5
,
10
,
,
fontsize
=
18
,
style
=
'oblique'
,
ha
=
'center'
,
va
=
'top'
,
wrap
=
True
)
(
3
,
4
,
,
family
=
'serif'
,
style
=
'italic'
,
ha
=
'right'
,
wrap
=
True
)
(
-
1
,
0
,
,
ha
=
'left'
,
rotation
=-
15
,
wrap
=
True
)
()
Total running time of the script: (0 minutes 2.015 seconds)