File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -261,17 +261,20 @@ def leaveEvent(self, event):
261
261
FigureCanvasBase .leave_notify_event (self , guiEvent = event )
262
262
263
263
def mouseEventCoords (self , pos ):
264
- """
265
- Calculate mouse coordinates in logical pixels.
264
+ """Calculate mouse coordinates in physical pixels
265
+
266
+ Qt5 use logical pixels, but the figure is scaled to physical
267
+ pixels for rendering. Transform to physical pixels so that
268
+ all of the down-stream transforms work as expected.
269
+
270
+ Also, the origin is different and needs to be corrected.
266
271
267
- Qt5 and Matplotlib use logical pixels, but the figure is scaled to
268
- physical pixels for rendering. Also, the origin is different and needs
269
- to be corrected.
270
272
"""
273
+ dpi_ratio = self ._dpi_ratio
271
274
x = pos .x ()
272
275
# flip y so y=0 is bottom of canvas
273
- y = self .figure .bbox .height / self . _dpi_ratio - pos .y ()
274
- return x , y
276
+ y = self .figure .bbox .height / dpi_ratio - pos .y ()
277
+ return x * dpi_ratio , y * dpi_ratio
275
278
276
279
def mousePressEvent (self , event ):
277
280
x , y = self .mouseEventCoords (event .pos ())
You can’t perform that action at this time.
0 commit comments