curious to see how it goes; in a nutshell:
- fine in jlab
- jb1: html output has the widgets, but they don’t interact (frozen output)
- jb2: not working at all, needs a kernel connection to display the widgets
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
from the doc (no graphic)¶
def f(x):
return x
interact(f, x=10);
Loading...
from the doc (with interactive_output)¶
import ipywidgets as widgets
from IPython.display import display
a = widgets.IntSlider(value=5, min=0, max=10)
def f1(a):
display(a)
def f2(a):
display(a * 2)
out1 = widgets.interactive_output(f1, {'a': a})
out2 = widgets.interactive_output(f2, {'a': a})
display(a)
display(out1)
display(out2)
Loading...
basic plot¶
%matplotlib ipympl
import ipywidgets as widgets
import numpy as np
import matplotlib.pyplot as plt
X = np.linspace(0, 4*np.pi, 200)
def frequency(f):
plt.clf()
Y = np.sin(f*X)
plt.plot(X, Y)
plt.show()
plt.figure()
interact(frequency, f=widgets.FloatSlider(min=1, max=10, value=2));
Loading...