November 2018
Beginner to intermediate
214 pages
5h 2m
English
We also use the drop-downs that ipywidgets provides. To start, let's insert interact (f, colour=colours), as follows:
# Dropdownsdef f(colour): plt.plot(np.arange(0,10), np.power(np.arange(0,10), 5), c=colour) plt.title("Power Law: $x=ay^b$")colours=['red', 'green', 'blue']interact(f, colour=colours)
A drop-down menu can be seen in the following output. When we select one of the colors from the drop-down, there is a switch between the color of the plot, which means that it's passing that argument to the C argument of the plot, as shown in the following output:

Read now
Unlock full access