一個pyplot.text藝術家使用kwarg包裝的當我運行此腳本:在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(-1, 0, t, ha='left', rotation=-15, wrap=True)
plt.show()
然後我收到此錯誤信息:
Traceback (most recent call last):
File "/home/eric/Desktop/tsd.py", line 10, in <module>
plt.text(4, 1, t, ha='left', rotation=15, wrap=True)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 3397, in text
ret = gca().text(x, y, s, fontdict=fontdict, withdash=withdash, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 3380, in text
t.update(kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 739, in update
raise AttributeError('Unknown property %s' % k)
AttributeError: Unknown property wrap
我執行的腳本直接複製來自matplotlib.org網頁http://matplotlib.org/devdocs/examples/text_labels_and_annotations/autowrap_demo.html。如何修復或配置我的系統以啓用換行功能?
我使用的是matplotlib 1.5,python 2.7和ubuntu 14.04。
謝謝!
如果關鍵字不工作,那麼您沒有使用1.5,那麼'matplotlib .__ version__'輸出的是什麼?我會'pip2安裝-u matplotlib'並保證它能正常工作 –
我可以用1.4.3重現這個錯誤信息。 1.5.0沒有錯誤信息,但也沒有包裝。 –
我現在意識到我有1.3版本。謝謝你讓我意識到。現在我的目標是安裝matplotlib 1.5。也許我必須爲此創建一個新問題。我試過[PIP2安裝-u matplotlib]在Linux終端,但它返回錯誤: 用法: 畫中畫安裝[選項] <要求符> ... PIP安裝[選項] -r <需求文件> ... pip install [options] [-e] ... pip install [options] [-e] ... pip install [options] ... 沒有這樣的選擇:-u 你知道其他方式來獲得我從GitHub和我我獲得matplotlib 1.5的源代碼在Ubuntu –
EricVonB