"According to this SO note, one should not import pyplot when embedding. It does funky things like running its own GUI with its own main loop."
If so, how can one pass the matplotlib.axes._axes.Axes argument necessary for a Slider without invoking plt.axes()? In the GUI based on matplotlib documentation, we have [added the following to include a slider]:
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)
The axpos line uses plt and creates its own figure separate from the Qt window. Note plt.axes returns a a matplotlib.axes._axes.Axes object not a matplotlib.axes._subplots.AxesSubplot object.
Similar questions:
When matplotlib is embedded in PyQt4 how are axes/subplots labelled without using pyplot?
Combining PyQt and Matplotlib