Agg
バックエンドを使用している場合、画像ウィンドウをshow()
(これにかかわらず、block=True
に関係なく)のままにしておくことはできません。私はAgg
を使用しない場合、私は警告を取得:python matplotlib Agg対対話プロットとtight_layout
/Library/Python/2.7/site-packages/matplotlib-1.2.0-py2.7-macosx-10.8-intel.egg/matplotlib/tight_layout.py:225: UserWarning: tight_layout : falling back to Agg renderer warnings.warn("tight_layout : falling back to Agg renderer")
サンプルコード:
import matplotlib as mpl
mpl.use('Agg') # With this line = figure disappears; without this line = warning
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
mu, sigma = 0, 0.5
x = np.linspace(-3, 3, 100)
plt.plot(x, mlab.normpdf(x, mu, sigma))
fig.tight_layout()
plt.show()
を私が使用する必要があり異なるバックエンドまたは方法はありますか?
デフォルトのバックエンドとは何ですか? 'import matplotlib as mpl'を実行してから' mpl.get_backend() 'を実行すると、あなたはどうしますか?これは、 "Agg"を指定していないときに使用するバックエンドになります。その2つのバックエンドのいずれかから別のバックエンドに切り替えることで、必要なものを手に入れることができます。 – BrenBarn
@zhermes:最終的に回避策を見つけましたか?私は同じ問題に直面しています。 – nia
回避策は、 'mpl.use( 'Agg')'を削除し、@FelipeCorreia – DilithiumMatrix