Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7db54c0

Browse filesBrowse files
committed
Using different corner to avoid off-by-one issue.
1 parent bbc1497 commit 7db54c0
Copy full SHA for 7db54c0

File tree

Expand file treeCollapse file tree

1 file changed

+7
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-4
lines changed

‎lib/matplotlib/backends/backend_qt5agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5agg.py
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ def paintEvent(self, event):
3838

3939
painter = QtGui.QPainter(self)
4040

41-
# get bounding box scaled to the figure
41+
# See documentation of QRect: bottom() and right() are off by 1, so use
42+
# left() + width() and top() + height().
4243
rect = event.rect()
43-
left, top = self.mouseEventCoords(rect.bottomLeft())
4444
width = rect.width() * self._dpi_ratio
4545
height = rect.height() * self._dpi_ratio
46-
# See documentation of QRect: bottom() and right() are off by 1, so use
47-
# left() + width() and top() + height().
46+
left, top = self.mouseEventCoords(rect.topLeft())
47+
# shift the "top" by the height of the image to get the
48+
# correct corner for our coordinate system
49+
top -= height
4850
bbox = Bbox([[left, top], [left + width, top + height]])
4951
# create a buffer using this bounding box
5052
reg = self.copy_from_bbox(bbox)
@@ -59,6 +61,7 @@ def paintEvent(self, event):
5961
if hasattr(qimage, 'setDevicePixelRatio'):
6062
# Not available on Qt4 or some older Qt5.
6163
qimage.setDevicePixelRatio(self._dpi_ratio)
64+
# set origin using original QT coordinates
6265
origin = QtCore.QPoint(rect.left(), rect.top())
6366
painter.drawImage(origin, qimage)
6467
# Adjust the buf reference count to work around a memory

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.