"これによると、SO noteは埋め込み時にpyplotをインポートすべきではありません。独自のメインループで独自のGUIを実行するような奇妙なことが起こります。組み込みqt4 GUIでpyplotをインポートするのを避けるには?
もしそうなら、plt.axes()を呼び出さずにSliderに必要なmatplotlib.axes._axes.Axes引数をどのように渡すことができますか?
def compute_initial_figure(self):
ymax = 300
window_size=1
res= 0.1
ax= self.axes
t = np.arange(0.0, 100.0, 0.1)
s = np.sin(2*np.pi*t)
ax.plot(t, s)
ax.axis([0, window_size, -ymax, ymax])
ax.get_xaxis().get_major_formatter().set_useOffset(False)
axcolor = 'lightgoldenrodyellow'
axpos = plt.axes([.1, .1, 0.75, 0.05], axisbg=axcolor) #MAKES OWN FIG!
spos = Slider(axpos, 'Time', res, t[-1], valinit=0)
spos.on_changed(update)
axposラインはPLTを使用し、独自の図は、Qtのウィンドウとは別の作成: はGUI based on matplotlib documentationでは、[スライダーを含めるために、次の追加]きました。メモplt.axesは、matplotlib.axes._subplots.AxesSubplotオブジェクトではなく、matplotlib.axes._axes.Axesオブジェクトを返します。
同様の質問:
When matplotlib is embedded in PyQt4 how are axes/subplots labelled without using pyplot?
Combining PyQt and Matplotlib
ページhttp://matplotlib.org/examples:次に、このようなadd_axesメソッドを呼び出す
:
ので、数字への参照を保持することに関連する行を変更します/user_interfaces/embedding_in_qt4.htmlは、そのような 'compute_initial_figure()'を持っていないようです。 –
これは修正されたcompute_initial_figure()です:スライダを含める。あなたの返信に感謝します。 – Rubenulis