I'm trying to share a github repo on binder. Locally, my interactive plot using matplotlib and @interact works ok. On binder it works half way. Same code adds static images to the cell output in binder notebook when slider value changes.
Question: how to fix binder behavior and make an interactive plot?
git repository https://github.com/queezz/Complex_Numbers
My notebook looks like this:
%pylab inline
from ipywidgets import interact, widgets
x = np.linspace(0,np.pi,100)
@interact
def plot_interactive(a=widgets.FloatSlider(min=1, max=10, val=1)):
plot(x,np.sin(x*a))
gca().set_aspect('equal')
ylim(-1.1,1.1)
Found a good working example: https://github.com/Kapernikov/ipywidgets-tutorial
The gist of it is to use
%matplotlib widget
and@widgets.interact
.It seems that usage of
%pylab inline
is discouraged now, see this git issue.I copy a part of the code from the tutorial which produces the same result as wanted in the question.