-
Notifications
You must be signed in to change notification settings - Fork 958
Open
Milestone
Description
Hi!
I deal with refresh matplotlib figure inside Output widget. The problem is that during update the Output completely disappears (or resizes to zero width / height) and appears again.
I can see this because the Button follows Output in VBox and it goes to the top for some milliseconds.
The idea is like follows but my code is very complex to be posted here. But this simple example works well and my program meets the problem.
What can cause such a problem?
PS. You can see I do ax.clear() and ax.plot(...) instead of ax.set_xdata(...) That is not occasionly because my logic needs to re-plot from zero.
%matplotlib inline
# To prevent automatic figure display when execution of the cell ends
%config InlineBackend.close_figures=False
import matplotlib.pyplot as plt
import numpy as np
from IPython.html import widgets
from IPython.display import display,clear_output
plt.ioff()
ax=plt.gca()
out=widgets.Output()
button=widgets.Button(description='Next')
vbox=widgets.VBox(children=(out,button))
display(vbox)
def click(b):
ax.clear()
ax.plot(np.random.randn(100),np.random.randn(100),'+')
with out:
clear_output(wait=True)
display(ax.figure)
button.on_click(click)
click(None)
sytelus and gumdropsteve
Metadata
Metadata
Assignees
Labels
No labels