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

Method scroll_zoom

lib/matplotlib/backend_tools.py:672–698  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

670 super().trigger(sender, event, data)
671
672 def scroll_zoom(self, event):
673 # https://gist.github.com/tacaswell/3144287
674 if event.inaxes is None:
675 return
676
677 if event.button == 'up':
678 # deal with zoom in
679 scl = self.base_scale
680 elif event.button == 'down':
681 # deal with zoom out
682 scl = 1/self.base_scale
683 else:
684 # deal with something that should never happen
685 scl = 1
686
687 ax = event.inaxes
688 ax._set_view_from_bbox([event.x, event.y, scl])
689
690 # If last scroll was done within the timing threshold, delete the
691 # previous view
692 if (time.time()-self.lastscroll) < self.scrollthresh:
693 self.toolmanager.get_tool(_views_positions).back()
694
695 self.figure.canvas.draw_idle() # force re-draw
696
697 self.lastscroll = time.time()
698 self.toolmanager.get_tool(_views_positions).push_current()
699
700
701class ToolZoom(ZoomPanBase):

Callers

nothing calls this directly

Calls 5

get_toolMethod · 0.80
_set_view_from_bboxMethod · 0.45
backMethod · 0.45
draw_idleMethod · 0.45
push_currentMethod · 0.45

Tested by

no test coverage detected