MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / press_zoom

Method press_zoom

lib/matplotlib/backend_bases.py:3253–3277  ·  view source on GitHub ↗

Callback for mouse button press in zoom to rect mode.

(self, event)

Source from the content-addressed store, hash-verified

3251 _ZoomInfo = namedtuple("_ZoomInfo", "button start_xy axes cid cbar")
3252
3253 def press_zoom(self, event):
3254 """Callback for mouse button press in zoom to rect mode."""
3255 if (event.button not in [MouseButton.LEFT, MouseButton.RIGHT]
3256 or event.x is None or event.y is None):
3257 return
3258
3259 axes = self._start_event_axes_interaction(event, method="zoom")
3260 if not axes:
3261 return
3262
3263 id_zoom = self.canvas.mpl_connect(
3264 "motion_notify_event", self.drag_zoom)
3265
3266 # A colorbar is one-dimensional, so we extend the zoom rectangle out
3267 # to the edge of the Axes bbox in the other dimension. To do that we
3268 # store the orientation of the colorbar for later.
3269 parent_ax = axes[0]
3270 if hasattr(parent_ax, "_colorbar"):
3271 cbar = parent_ax._colorbar.orientation
3272 else:
3273 cbar = None
3274
3275 self._zoom_info = self._ZoomInfo(
3276 button=event.button, start_xy=(event.x, event.y), axes=axes,
3277 cid=id_zoom, cbar=cbar)
3278
3279 def drag_zoom(self, event):
3280 """Callback for dragging in zoom mode."""

Callers 2

_zoom_pan_handlerMethod · 0.95

Calls 2

mpl_connectMethod · 0.80

Tested by 1