%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from ipywidgets import interact, FloatSlider
def myplot(a):
xs = np.linspace(-3,3,100)
ys = np.sin(a*xs)
plt.plot(xs,ys)
demo = interact(myplot, a=FloatSlider(value=1, min=-3, max=3, step=0.01))
--
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 jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/c512ae9a-e66a-4f81-b6ef-f79fd6bf5d6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The problem is that the rendering logic for matplotlib resides in the backend. I would recommand using the "notebook" backend for matplotlib which should improve the situation.Or you can use a plotting library for the notebook such as bqplot.
import numpy as np
from bqplot import pyplot as plt
from ipywidgets import interact, FloatSlider
fig = plt.figure(1)
def myplot(a):
xs = np.linspace(-3,3,100)
ys = np.sin(a*xs)
if fig.marks == []:
plt.plot(xs,ys)
else:
fig.marks[0].y = ys
demo = interact(myplot, a=FloatSlider(value=1, min=-3, max=3, step=0.01))
plt.ylim(-1.1,1.1)
plt.show()
import numpy as npimport bqplot.pyplot as plt
from ipywidgets import interact, FloatSlider
fig = plt.figure()xs = np.linspace(-3,3,100)lines = plt.plot(xs, [])def freq(a):lines.y = np.sin(a * xs)demo = interact(freq, a=FloatSlider(value=1, min=-3, max=3, step=0.01))plt.ylim(-1.1,1.1)plt.show()
animation_duration=300
--
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 jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/1d4935fd-b035-4c7f-bbf7-8aa04ed20d4b%40googlegroups.com.
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: