9

バックエンドを使用すると、 (かどうかに関係なく)Agg画像ウィンドウを開いたままにすることができません---それらは事実上すぐに閉じます。を使用しない場合、警告が表示されます。show()block=TrueAgg

/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()

使用すべき別のバックエンドまたは方法論はありますか?

4

2 に答える 2

7

コメントで@FilipeCorreiaによって与えられた回避策は、を削除し、の代わりにmpl.use('Agg')使用することです。fig.set_tight_layout(True)fig.tight_layout()

于 2015-02-22T21:02:54.257 に答える
6

Agg非対話型のバックエンドです。つまり、画面には表示されず、ファイルに保存するだけです。どのバックエンドを使用していますか?あなたはOSXを持っています、おそらくあなたは「macosx」、またはAggを使用するインタラクティブなバックエンド(例えば、QT4Agg、WXAgg)を試すことができます。

于 2013-03-17T00:26:42.203 に答える