@@ -2792,7 +2792,10 @@ def dynamic_update(self):
27922792 self .canvas .draw_idle ()
27932793
27942794 def draw_rubberband (self , event , x0 , y0 , x1 , y1 ):
2795- """Draw a rectangle rubberband to indicate zoom limits."""
2795+ """Draw a rectangle rubberband to indicate zoom limits.
2796+
2797+ Note that it is not guaranteed that ``x0 <= x1`` and ``y0 <= y1``.
2798+ """
27962799
27972800 def remove_rubberband (self ):
27982801 """Remove the rubberband."""
@@ -3041,20 +3044,13 @@ def drag_zoom(self, event):
30413044 if self ._xypress :
30423045 x , y = event .x , event .y
30433046 lastx , lasty , a , ind , view = self ._xypress [0 ]
3044-
3045- # adjust x, last, y, last
3046- x1 , y1 , x2 , y2 = a .bbox .extents
3047- x , lastx = max (min (x , lastx ), x1 ), min (max (x , lastx ), x2 )
3048- y , lasty = max (min (y , lasty ), y1 ), min (max (y , lasty ), y2 )
3049-
3047+ (x1 , y1 ), (x2 , y2 ) = np .clip (
3048+ [[lastx , lasty ], [x , y ]], a .bbox .min , a .bbox .max )
30503049 if self ._zoom_mode == "x" :
3051- x1 , y1 , x2 , y2 = a .bbox .extents
3052- y , lasty = y1 , y2
3050+ y1 , y2 = a .bbox .intervaly
30533051 elif self ._zoom_mode == "y" :
3054- x1 , y1 , x2 , y2 = a .bbox .extents
3055- x , lastx = x1 , x2
3056-
3057- self .draw_rubberband (event , x , y , lastx , lasty )
3052+ x1 , x2 = a .bbox .intervalx
3053+ self .draw_rubberband (event , x1 , y1 , x2 , y2 )
30583054
30593055 def release_zoom (self , event ):
30603056 """Callback for mouse button release in zoom to rect mode."""
0 commit comments