Text box with line wrapping in matplotlib?

Viewed 55860

Is it possible to display text in a box through Matplotlib, with automatic line breaks? By using pyplot.text(), I was only able to print multi-line text that flows beyond the boundaries of the window, which is annoying. The size of the lines is not known in advance… Any idea would be much appreciated!

3 Answers

By setting wrap = True when creating the text box, as in the below example. This may have the desired effect.

plt.text(5, 5, t, ha='right', rotation=-15, wrap=True)
Related