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

Skip to content

Commit 3bf8dcc

Browse files
jbhopkinstacaswell
authored andcommitted
Fixes zoom rubberband display on macOS w/ wxagg and multiple subplots (matplotlib#9005)
* Fixed a bug where the zoom rubberband didn't display properly on macOS when using the wxagg backend and multiple subfigures. * Made zoomAxes private, released the axes reference when the rubberband is done. * Made zoomAxes public again. * Made zoomaxes release consistent with prevZoomRect release.
1 parent 95e5655 commit 3bf8dcc

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,10 +1614,12 @@ def press(self, event):
16141614
if not self.retinaFix:
16151615
self.wxoverlay = wx.Overlay()
16161616
else:
1617-
self.savedRetinaImage = self.canvas.copy_from_bbox(
1618-
self.canvas.figure.gca().bbox)
1619-
self.zoomStartX = event.xdata
1620-
self.zoomStartY = event.ydata
1617+
if event.inaxes is not None:
1618+
self.savedRetinaImage = self.canvas.copy_from_bbox(
1619+
event.inaxes.bbox)
1620+
self.zoomStartX = event.xdata
1621+
self.zoomStartY = event.ydata
1622+
self.zoomAxes = event.inaxes
16211623

16221624
def release(self, event):
16231625
if self._active == 'ZOOM':
@@ -1631,6 +1633,8 @@ def release(self, event):
16311633
if self.prevZoomRect:
16321634
self.prevZoomRect.pop(0).remove()
16331635
self.prevZoomRect = None
1636+
if self.zoomAxes:
1637+
self.zoomAxes = None
16341638

16351639
def draw_rubberband(self, event, x0, y0, x1, y1):
16361640
if self.retinaFix: # On Macs, use the following code
@@ -1643,10 +1647,10 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
16431647
Y0, Y1 = self.zoomStartY, event.ydata
16441648
lineX = (X0, X0, X1, X1, X0)
16451649
lineY = (Y0, Y1, Y1, Y0, Y0)
1646-
self.prevZoomRect = self.canvas.figure.gca().plot(
1650+
self.prevZoomRect = self.zoomAxes.plot(
16471651
lineX, lineY, '-', color=rubberBandColor)
1648-
self.canvas.figure.gca().draw_artist(self.prevZoomRect[0])
1649-
self.canvas.blit(self.canvas.figure.gca().bbox)
1652+
self.zoomAxes.draw_artist(self.prevZoomRect[0])
1653+
self.canvas.blit(self.zoomAxes.bbox)
16501654
return
16511655

16521656
# Use an Overlay to draw a rubberband-like bounding box.

0 commit comments

Comments
 (0)