Вы можете использовать \n
, чтобы указать, где вы собираетесь разбить текст на несколько строк:
import matplotlib.pyplot as plt
fig = plt.figure()
plt.axis([0, 10, 0, 10])
t = ("This is a really long string that I'd rather have wrapped so that it \n"
"doesn't go outside of the figure, but if it's long enough it will go \n"
"off the top or bottom!")
plt.text(4, 1, t, ha='left', rotation=15)
plt.text(6, 5, t, ha='left', rotation=15)
plt.text(5, 5, t, ha='right', rotation=-15)
plt.text(5, 10, t, fontsize=18, style='oblique', ha='center',
va='top')
plt.text(3, 4, t, family='serif', style='italic', ha='right')
plt.text(-1, 0, t, ha='left', rotation=-15)
plt.show()