similar questionがありますが、そこで提案されている解決策を作成することはできません。どのように長いタイトルに合うのですか?
ここでは、長いタイトルのプロット例です:それは
AttributeError: 'module' object has no attribute 'tight_layout'
を与え、私はfig.tight_layout()
で(matplotlib.pyplot).tight_layout()
を交換した場合、それが与える
#!/usr/bin/env python
import matplotlib
import matplotlib.pyplot
import textwrap
x = [1,2,3]
y = [4,5,6]
# initialization:
fig = matplotlib.pyplot.figure(figsize=(8.0, 5.0))
# lines:
fig.add_subplot(111).plot(x, y)
# title:
myTitle = "Some really really long long long title I really really need - and just can't - just can't - make it any - simply any - shorter - at all."
fig.add_subplot(111).set_title("\n".join(textwrap.wrap(myTitle, 80)))
# tight:
(matplotlib.pyplot).tight_layout()
# saving:
fig.savefig("fig.png")
:
AttributeError: 'Figure' object has no attribute 'tight_layout'
だから私の質問私はプロットにタイトルをどのように適合させるのですか?リンクされ、追加改行を伴う他のいくつかの優れたソリューションです答えでは
import pylab as plt
plt.rcParams["axes.titlesize"] = 8
myTitle = "Some really really long long long title I really really need - and just can't - just can't - make it any - simply any - shorter - at all."
plt.title(myTitle)
plt.show()
:それを行うには
'tight_layout'はmatplotlibののリリースの最後のカップルです。どのバージョンを使用していますか? 'tight_layout'が1.1に追加されたと思いますが、1.0だったかもしれません。 –
鉱山は '1.0.1'です。 – Adobe
@ジョーキングトン:おそらくあなたの権利:あなたの[答え](http://stackoverflow.com/a/9604442/788700)を再現すると同じエラーが発生します。私は最新のソースをダウンロードしています。 – Adobe