Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d23ebc9

Browse files
authored
Merge pull request #11712 from anntzer/retinaqt
Fix drawing on qt+retina.
2 parents 0766e53 + 3e3b538 commit d23ebc9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ def paintEvent(self, event):
4444
height = rect.height()
4545
# See documentation of QRect: bottom() and right() are off by 1, so use
4646
# left() + width() and top() + height().
47-
bbox = Bbox([[left, self.renderer.height - (top + height)],
48-
[left + width, self.renderer.height - top]])
47+
bbox = Bbox(
48+
[[left, self.renderer.height - (top + height * self._dpi_ratio)],
49+
[left + width * self._dpi_ratio, self.renderer.height - top]])
4950
reg = self.copy_from_bbox(bbox)
5051
buf = reg.to_string_argb()
51-
qimage = QtGui.QImage(buf, width, height, QtGui.QImage.Format_ARGB32)
52+
qimage = QtGui.QImage(
53+
buf, width * self._dpi_ratio, height * self._dpi_ratio,
54+
QtGui.QImage.Format_ARGB32)
5255
if hasattr(qimage, 'setDevicePixelRatio'):
5356
# Not available on Qt4 or some older Qt5.
5457
qimage.setDevicePixelRatio(self._dpi_ratio)

0 commit comments

Comments
 (0)