How to view the different kinds of widgets that ipywidgets provides

We also use the drop-downs that ipywidgets provides. To start, let's insert interact (f, colour=colours), as follows:

# Dropdowns
def 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:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset