-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Plot disappears after updating its data for the second time in Jupiter Notebook #15076
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
GUI: nbaggstatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
Description
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
import ipywidgets as widgets
import matplotlib.pyplot as plt
import numpy as np
%matplotlib widget
# or %matplotlib notebook
plt.ioff()
figures = {}
fig, ax = plt.subplots()
def update_plot(value):
x, y = np.random.random(10), np.random.random(10)
l = [_ for _ in zip(x, y)]
if len(ax.lines) == 0: # first call to function
ax.plot(x,y)
plt.show()
else: # all following calls
ax.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_box
display(grid)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,
- Browser: tested in Safari and Firefox
Installed via brew and pip
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
GUI: nbaggstatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
