November 2018
Beginner to intermediate
214 pages
5h 2m
English
In the case where we want a drop-down that does not necessarily pass a string, a dictionary can be passed, as shown in the following code:
# Dropdowns with dictsdef f(b): plt.plot(np.arange(0,10), np.power(np.arange(0,10), b)) plt.title("Power Law: $x=ay^b$")powers = {'one':1, 'two':2, 'three':3}interact(f, b=powers)
In the following output, we have a dictionary with strings for keys. Here, we are passing an integer to the index of the power law.
For power one, we get the following output:

For power three, we get the following output:
Hence, ipywidgets provides a simple way of going from zero to interactivity in no ...
Read now
Unlock full access