![]() ![]() Cursor()function and all the input parameters used in the present example. Use blitting for improving the performance #PlottingĪxes defining the space in which the button will be located To this purpose, we entirely rely on the matplotlib.pyplotpackage. In the next step we define the plotting window and plot our function. All these procedures are described in the following code-lines. Of course, this is only one possible example, any function is good for the final goal of this article. ![]() The “y” array is defined by the following function:īoth the sin() and the exponential function are introduced using NumPy. linspace(), which will generate an array of 100 equally spaced numbers from 0 to 10. The “x” array is defined by exploiting the NumPy function. In order to use our cursor on a real plot, we introduce an initial function by defining two NumPy arrays, “x” and “y”. Finally, from the matplotlib.widgetpackage, we import the function Cursor, which will be used for the creation of the interactive cursor. We will use NumPyfor defining an initial function that will be then displayed using matplotlib.pyplot. # Unzipping the coord list in two different arraysĪs to begin, we import the libraries and the packages that will be used in this example. # printing the values of the selected pointįig.canvas.mpl_connect('button_press_event', onclick) # Function for storing and showing the clicked values ![]() #x and y arrays for definining an initial functionĬursor = Cursor(ax, horizOn=True, vertOn=True, useblit=True,Īnnot = ax.annotate("", xy=(0,0), xytext=(-40,40),textcoords="offset points",ībox=dict(boxstyle='round4', fc='linen',ec='k',lw=1), Every time a point on the window is clicked with the cursor, an annotating box containing the values of the point coordinates is displayed.Īnd here’s the code that we’ll discuss in this article that leads to this output: import numpy as np ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |