December 2017
Intermediate to advanced
386 pages
10h 42m
English
We start by defining a function that creates a plot, naming it plot_function(). This function takes one argument, ratio, which is the variable that the user will control interactively. Notice that we specify a default value for the ratio argument, with the ratio=0.1 option. This default value is used as the initial value of the interactive variable.
In the body of plot_function(), we construct a Matplotlib graph using the usual commands. Notice, however, that we add a call to show() at the end of the function. This is necessary to make the function work correctly with Jupyter's display system.
The interact is set up with the following call:
interact(plot_function, ratio=(0.1, 1.1, 0.01))
The first argument to interact() is the ...
Read now
Unlock full access