Closed alexrockhill closed 2 years ago
It turns out you just can't use Output
, I should have read the comprehensive example more closely, the last part was very explanatory!
This works:
%matplotlib widget
import matplotlib.pyplot as plt
from ipywidgets import HBox, Output, Label, Widget, IntSlider
from ipympl.backend_nbagg import Canvas
plt.ioff()
fig = plt.figure()
plt.ion()
ax = fig.add_subplot(111)
ax.plot(range(10))
slider = IntSlider(value=0, min=0, max=10)
HBox([slider, fig.canvas])
It's a bit tricky to abstract the canvas as a class but it works and that's great!
ipywidget
layouts no longer acceptmatplotlib
FigureCanvas
s as children because they are not widgets. If you wrap that in an output (see code below) as seems like a natural solution, you don't get the output in the layout, rather it is just appended to the bottom of the plot usingsys.displayhook
as far as I can tell. This prevents you from making a nice layout with multiple plots side-by-side for instance.Versions
Example
Test should come after canvas here:
https://github.com/mne-tools/mne-python/pull/10803 Similar to https://github.com/matplotlib/ipympl/issues/203