In this section, we present the basic components11.1 A guiding example to widgets of a widget and their counterparts in Python. We do this by using the guiding example displayed in the following figure:
Figure 11.1: A widget to display
 for user-given frequencies ![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/9517305e-55a6-4f64-b1c6-3abe53043510.png)
![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/b7925514-4664-4123-958a-9553478a9f75.png)
![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/9517305e-55a6-4f64-b1c6-3abe53043510.png)
In this figure, we see a slider bar at the top. With the use of a computer mouse, the blue bar can be moved from left to right and the value for , ranging between 1 and 5, is displayed on the right of the bar.
Correspondingly, the frequency of the sine wave displayed in the plot window changes.
This widget consists of three parts:
- A figure object with an axes object and the plot
- An axes object containing a slider object
- A call-back function for updating the plot as soon as the slider value changes
We discussed how to program the first part, in Section 6.2: Working with Matplotlib objects directly.
In the following code snippet, we first create a figure with a given size and...