- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to show mouse release event coordinates with Matplotlib?
To show mouse release event coordinates with matplotlib, we can take the following steps−
- Set the figure size and adjust the padding between and around the subplots.
- Create a figure and a set of subplots.
- Plot a line in the range of 10.
- Bind the function *onclick* to the event *button_release_event*.
- Print event and its x and y data.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt plt.rcParams['backend'] = 'TkAgg' plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True def onclick(event): print(event.button, event.xdata, event.ydata) fig, ax = plt.subplots() ax.plot(range(10)) fig.canvas.mpl_connect('button_release_event', onclick) plt.show()
Output
MouseButton.LEFT 4.961566107601828 1.6644009000562534 MouseButton.LEFT 6.782345894140708 3.7026907931745727 MouseButton.LEFT 2.98552602918754 7.177807987999249
- Related Articles
- Store mouse click event coordinates with Matplotlib
- Matplotlib – How to show the coordinates of a point upon mouse click?
- How can I show image rollover with a mouse event in JavaScript?
- How to make Matplotlib show all X coordinates?
- How to draw a line following mouse coordinates with tkinter?
- JavaScript – Getting Coordinates of mouse
- How to handle a mouse right click event using jQuery?
- How to disable mouse event on certain elements using JavaScript?
- Mouse event not being triggered on HTML5 canvas? How to solve it?
- How to get pixel coordinates for Matplotlib-generated scatterplot?
- How to get coordinates from the contour in matplotlib?
- How to show Matplotlib in Flask?
- How to plot bar graphs with same X coordinates side by side in Matplotlib?
- How to bind a Tkinter event to the left mouse button being held down?
- How to show multiple colorbars in Matplotlib?

Advertisements