You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plot is created and can be updated via a widget, but disappears after the second time the object data is modified.
To properly place the figure within a GridSpec layout, interactive mode is turned off and the figure is not created until the widget's associated function is first called.
Code for reproduction
importipywidgetsaswidgetsimportmatplotlib.pyplotaspltimportnumpyasnp%matplotlibwidget# or %matplotlib notebookplt.ioff()
figures= {}
fig, ax=plt.subplots()
defupdate_plot(value):
x, y=np.random.random(10), np.random.random(10)
l= [_for_inzip(x, y)]
iflen(ax.lines) ==0: # first call to functionax.plot(x,y)
plt.show()
else: # all following callsax.lines[0].set_xdata(x)
ax.lines[0].set_ydata(y)
fig.canvas.draw_idle()
my_widget=widgets.FloatSlider(min=0.1, max=0.9, step=0.1, value=0.5)
my_widget_box=widgets.interactive(update_plot, value=my_widget)
grid=widgets.GridspecLayout(2, 2, layout=widgets.Layout(justify_content='center'))
grid[0, 0] =my_widget_boxdisplay(grid)
Actual outcome
Expected outcome
Figure does not disappear
Matplotlib version
Operating system: macOs
Matplotlib version: 3.1.1.
Matplotlib backend (print(matplotlib.get_backend())): "module://ipympl.backend_nbagg" (%matplotlib widget) or "nbAgg" (%matplotlib notebook)
Python version: 3.7.4
Jupyter version (if applicable): 1.0.0
Other libraries: ipywidgets==7.5.1, ipympl==0.3.3,
Bug report
Plot is created and can be updated via a widget, but disappears after the second time the object data is modified.
To properly place the figure within a GridSpec layout, interactive mode is turned off and the figure is not created until the widget's associated function is first called.
Code for reproduction
Actual outcome

Expected outcome
Figure does not disappear
Matplotlib version
print(matplotlib.get_backend())): "module://ipympl.backend_nbagg" (%matplotlib widget) or "nbAgg" (%matplotlib notebook)Installed via brew and pip