Here is the explanation of the code:
- The first four steps are already familiar to you.
- ax_s = plt.axes([0.15, 0.05, 0.25, 0.05]) defines the axes on which the Slider widget is to be placed.
- slider_n = Slider(ax_s, '#of leaves', 3, 10, valinit=initial_n, valstep=1.0) defines the slider:
- The first argument is the axes reference, the second one is the label to be displayed on the slider in the figure.
- Three is the minimum value, that is, the starting point, and 10 is the maximum value of the slider bar. So, by dragging the slider with the mouse, the value changes from 3 to 10.
- valinit specifies the starting point on the slider, when the figure gets displayed the first time. Here, we have specified it as 4.
- valstep specifies ...