10000 FIX: always eraseRect in Qt widget · matplotlib/matplotlib@79ed0ee · GitHub
[go: up one dir, main page]

Skip to content

Commit 79ed0ee

Browse files
committed
FIX: always eraseRect in Qt widget
Re-focusing the figure window will call the draw method. If the facecolor of the figure and axes are transparent and we do not erase the widget we are effectively compositing the figure on to its self which results in artifacts anywhere there is alpha or anti-aliasing. Closes #13012
1 parent 4aa2708 commit 79ed0ee

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ def __init__(self, figure):
240240
self._dpi_ratio_prev = None
241241

242242
self._draw_pending = False
243-
self._erase_before_paint = False
244243
self._is_drawing = False
245244
self._draw_rect_callback = lambda painter: None
246245

@@ -491,7 +490,6 @@ def draw(self):
491490
return
492491
with cbook._setattr_cm(self, _is_drawing=True):
493492
super().draw()
494-
self._erase_before_paint = True
495493
self.update()
496494

497495
def draw_idle(self):

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ def paintEvent(self, event):
3838

3939
painter = QtGui.QPainter(self)
4040

41-
if self._erase_before_paint:
42-
painter.eraseRect(self.rect())
43-
self._erase_before_paint = False
44-
4541
rect = event.rect()
4642
left = rect.left()
4743
top = rect.top()
@@ -55,6 +51,10 @@ def paintEvent(self, event):
5551
reg = self.copy_from_bbox(bbox)
5652
buf = cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
5753
memoryview(reg))
54+
55+
# clear the widget canvas
56+
painter.eraseRect(rect)
57+
5858
qimage = QtGui.QImage(buf, buf.shape[1], buf.shape[0],
5959
QtGui.QImage.Format_ARGB32_Premultiplied)
6060
if hasattr(qimage, 'setDevicePixelRatio'):

0 commit comments

Comments
 (0)
0