Jupyter: How To Update Plot On Button Click (ipywidgets)
I am using Jupyter and trying to make my plots interactive. So I have a plot. I have a ipywidgets button. On button click I need to update plot, like interact do with sliders. But
Solution 1:
As workaround we can repaint the whole plot to Output widget and then display it without flickering.
%matplotlib inline
from matplotlib.pyplot import *
button = ipywidgets.Button(description="Button")
out = ipywidgets.Output()
def on_button_clicked(b):
with out:
clear_output(True)
plot([1,2],[2,1])
show()
button.on_click(on_button_clicked)
display(button)
with out:
plot([1,2],[1,2])
show()
out
Post a Comment for "Jupyter: How To Update Plot On Button Click (ipywidgets)"