This is the matplotlib version with manual data assignment, which is
probably the most efficient you can make something like this without making
the code a lot uglier and harder to understand.  It's the MPL equivalent of
what Sylvain did:

#### Start
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from ipywidgets import interact, FloatSlider
from IPython.display import display

# setup
xs = np.linspace(-3,3,100)
fig, ax = plt.subplots()
line, = ax.plot(xs, xs)
ax.set_xlim(-3, 3)
ax.set_ylim(-1.1, 1.1)
plt.close(fig) # we'll display it manually

# Plot function only updates the data
def myplot(a):
    line.set_ydata(np.sin(a*xs))
    # we now call the display manually with the new image
    display(fig)

interact(myplot, a=FloatSlider(value=1.5, min=-3, max=3, step=0.01));
#### End


Cheers,

f

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAHAreOqRWam_BhESKCJTq-kQShCW6bfP5LOB5s8OhehWg7O-%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to