Skip to content

Commit 1cc671b

Browse files
committed
fixes issue with using transparency for the figure patch and
being able to see shadows of previous draws underneath. see: http://stackoverflow.com/questions/18944561/matplotlib-pyqt4-transparent-figure Added some documentation to `paintEvent`
1 parent fc94ddb commit 1cc671b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/matplotlib/backends/backend_qt4agg.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,16 @@ def paintEvent( self, e ):
102102

103103
refcnt = sys.getrefcount(stringBuffer)
104104

105+
# convert the Agg rendered image -> qImage
105106
qImage = QtGui.QImage(stringBuffer, self.renderer.width,
106107
self.renderer.height,
107108
QtGui.QImage.Format_ARGB32)
109+
# get the rectangle for the image
110+
rect = qImage.rect()
108111
p = QtGui.QPainter(self)
112+
# reset the image area of the canvas to be the back-ground color
113+
p.eraseRect(rect)
114+
# draw the rendered image on to the canvas
109115
p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))
110116

111117
# draw the zoom rectangle to the QPainter

0 commit comments

Comments
 (0)