diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index c6dd94a9c47e..81d043f6d7a5 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -2777,7 +2777,13 @@ def format_coord(self, x, y): def can_zoom(self): """ - Return *True* if this axes support the zoom box + Return *True* if this axes supports the zoom box button functionality. + """ + return True + + def can_pan(self) : + """ + Return *True* if this axes supports any pan/zoom button functionality. """ return True diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index aedb15abe2b4..4d7bcd43a35b 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2512,11 +2512,13 @@ def press_pan(self, event): self._xypress=[] for i, a in enumerate(self.canvas.figure.get_axes()): - if x is not None and y is not None and a.in_axes(event) and a.get_navigate(): + if (x is not None and y is not None and a.in_axes(event) and + a.get_navigate() and a.can_pan()) : a.start_pan(x, y, event.button) self._xypress.append((a, i)) self.canvas.mpl_disconnect(self._idDrag) - self._idDrag=self.canvas.mpl_connect('motion_notify_event', self.drag_pan) + self._idDrag=self.canvas.mpl_connect('motion_notify_event', + self.drag_pan) self.press(event) @@ -2537,9 +2539,10 @@ def press_zoom(self, event): self._xypress=[] for i, a in enumerate(self.canvas.figure.get_axes()): - if x is not None and y is not None and a.in_axes(event) \ - and a.get_navigate() and a.can_zoom(): - self._xypress.append(( x, y, a, i, a.viewLim.frozen(), a.transData.frozen())) + if (x is not None and y is not None and a.in_axes(event) and + a.get_navigate() and a.can_zoom()) : + self._xypress.append(( x, y, a, i, a.viewLim.frozen(), + a.transData.frozen() )) id1 = self.canvas.mpl_connect('motion_notify_event', self.drag_zoom) diff --git a/lib/matplotlib/projections/geo.py b/lib/matplotlib/projections/geo.py index 84a21c947060..8a20f5c2768d 100644 --- a/lib/matplotlib/projections/geo.py +++ b/lib/matplotlib/projections/geo.py @@ -218,7 +218,17 @@ def get_data_ratio(self): def can_zoom(self): """ - Return True if this axes support the zoom box + Return *True* if this axes supports the zoom box button functionality. + + This axes object does not support interactive zoom box. + """ + return False + + def can_pan(self) : + """ + Return *True* if this axes supports the pan/zoom button functionality. + + This axes object does not support interactive pan/zoom. """ return False diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index c4589040574a..ec5526cddcb1 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -572,10 +572,22 @@ def get_data_ratio(self): def can_zoom(self): """ - Return True if this axes support the zoom box + Return *True* if this axes supports the zoom box button functionality. + + Polar axes do not support zoom boxes. """ return False + def can_pan(self) : + """ + Return *True* if this axes supports the pan/zoom button functionality. + + For polar axes, this is slightly misleading. Both panning and + zooming are performed by the same button. Panning is performed + in azimuth while zooming is done along the radial. + """ + return True + def start_pan(self, x, y, button): angle = self._r_label1_position.to_values()[4] / 180.0 * np.pi mode = '' diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 267beb9f9f24..65be58e1dd16 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -806,6 +806,19 @@ def mouse_init(self, rotate_btn=1, zoom_btn=3): self._zoom_btn = np.atleast_1d(zoom_btn) def can_zoom(self) : + """ + Return *True* if this axes supports the zoom box button functionality. + + 3D axes objects do not use the zoom box button. + """ + return False + + def can_pan(self) : + """ + Return *True* if this axes supports the pan/zoom button functionality. + + 3D axes objects do not use the pan/zoom button. + """ return False def cla(self):