Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 067f9b6 commit 419da79Copy full SHA for 419da79
lib/matplotlib/backends/backend_qt5.py
@@ -263,9 +263,16 @@ def leaveEvent(self, event):
263
FigureCanvasBase.leave_notify_event(self, guiEvent=event)
264
265
def mouseEventCoords(self, pos):
266
- x = pos.x() * self._dpi_ratio
+ """
267
+ Calculate mouse coordinates in logical pixels.
268
+
269
+ Qt5 and Matplotlib use logical pixels, but the figure is scaled to
270
+ physical pixels for rendering. Also, the origin is different and needs
271
+ to be corrected.
272
273
+ x = pos.x()
274
# flip y so y=0 is bottom of canvas
- y = self.figure.bbox.height - pos.y() * self._dpi_ratio
275
+ y = self.figure.bbox.height / self._dpi_ratio - pos.y()
276
return x, y
277
278
def mousePressEvent(self, event):
0 commit comments