This section describes a selection of the different kinds of widgets along with how to add interactivity to these widgets using callbacks.
GUI neutral widgets
How to add the basic GUI neutral widgets
We will begin by taking a look at cursor. The cursor will generate a widget that places little x axis and y axis cursors over the top of the axis. The first argument to any widget is the axis that we want to attach it to. In this case, we want to attach it to the current axis. By doing this, by default, it should look unchanged.
- However, as we hover over the plot, we get the XY cursor, as shown in the following output after the code:
# Basic cursor
nums = np.arange(0,10,0.1)
plt.plot(nums, np.sin(nums))
Cursor(plt.gca())
Following...