【发布时间】:2018-01-03 14:29:45
【问题描述】:
我正在尝试使用 wrap=True 换行文本,但它似乎对我不起作用。从下面的 matplotlib 运行示例:
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"\
" doesn't go outside of the figure, but if it's long enough it will go"\
" off the top or bottom!"
plt.text(4, 1, t, ha='left', rotation=15, wrap=True)
plt.text(6, 5, t, ha='left', rotation=15, wrap=True)
plt.text(5, 5, t, ha='right', rotation=-15, wrap=True)
plt.text(5, 10, t, fontsize=18, style='oblique', ha='center',
va='top', wrap=True)
plt.text(3, 4, t, family='serif', style='italic', ha='right', wrap=True)
plt.text(-1, 0, t, ha='left', rotation=-15, wrap=True)
plt.show()
给我这个:
文本换行出错
有什么想法吗?
【问题讨论】:
-
在 Python 3.4 和 matplotlib 2.1.1 上为我工作。你用的是什么版本的 Python 和 matplotlib?
-
您好,这是 Anaconda #705 自 2016 年 3 月 15 日以来的问题。问题仍然存在。我刚刚在那里发表了评论,问题仍然存在。
-
使用 matplotlib 2.1.0 运行 Anaconda/python 3.6.3
标签: python matplotlib text