@@ -73,6 +73,7 @@ def __init__(self, **kwargs):
73
73
self .touch_mode = 'pan'
74
74
self .hover_on = False
75
75
self .xsorted = True #to manage x sorted data (if numpy is used)
76
+ self .minzoom = dp (40 ) #minimum pixel distance to apply zoom
76
77
77
78
#zoom box coordonnate
78
79
self .x0_box = None
@@ -449,7 +450,14 @@ def on_touch_up(self, event):
449
450
450
451
x , y = event .x , event .y
451
452
if abs (self ._box_size [0 ]) > 1 or abs (self ._box_size [1 ]) > 1 or self .touch_mode == 'zoombox' :
452
- self .reset_box ()
453
+ self .reset_box ()
454
+ if not self .collide_point (x , y ) and self .do_update :
455
+ #update axis lim if zoombox is used and touch outside widget
456
+ self .update_lim ()
457
+ ax = self .axes
458
+ ax .figure .canvas .draw_idle ()
459
+ ax .figure .canvas .flush_events ()
460
+ return True
453
461
454
462
# stop propagating if its within our bounds
455
463
if self .collide_point (x , y ):
@@ -511,8 +519,8 @@ def apply_pan(self, ax, event):
511
519
512
520
cur_xlim = ax .get_xlim ()
513
521
cur_ylim = ax .get_ylim ()
514
- cur_xlim -= dx
515
- cur_ylim -= dy
522
+ cur_xlim -= dx / 2
523
+ cur_ylim -= dy / 2
516
524
ax .set_xlim (cur_xlim )
517
525
ax .set_ylim (cur_ylim )
518
526
@@ -598,7 +606,7 @@ def update_lim(self):
598
606
599
607
def reset_box (self ):
600
608
""" reset zoombox and apply zoombox limit if zoombox option if selected"""
601
- if abs (self ._box_size [0 ])> dp ( 50 ) and abs (self ._box_size [1 ])> dp ( 50 ) :
609
+ if min ( abs (self ._box_size [0 ]), abs (self ._box_size [1 ])) > self . minzoom :
602
610
trans = self .axes .transData .inverted ()
603
611
self .x0_box , self .y0_box = trans .transform_point ((self ._box_pos [0 ], self ._box_pos [1 ]- self .pos [1 ]))
604
612
self .x1_box , self .y1_box = trans .transform_point ((self ._box_size [0 ]+ self ._box_pos [0 ], self ._box_size [1 ]+ self ._box_pos [1 ]- self .pos [1 ]))
@@ -675,7 +683,7 @@ def draw_box(self, event, x0, y0, x1, y1) -> None:
675
683
else :
676
684
y0 = y0_max [0 ][1 ]+ pos_y
677
685
678
- if abs (x1 - x0 )< dp (20 ) and abs (y1 - y0 )> dp ( 50 ) :
686
+ if abs (x1 - x0 )< dp (20 ) and abs (y1 - y0 )> self . minzoom :
679
687
self .pos_x_rect_ver = x0
680
688
self .pos_y_rect_ver = y0
681
689
@@ -687,7 +695,7 @@ def draw_box(self, event, x0, y0, x1, y1) -> None:
687
695
688
696
self ._alpha_ver = 1
689
697
690
- elif abs (y1 - y0 )< dp (20 ) and abs (x1 - x0 )> dp ( 50 ) :
698
+ elif abs (y1 - y0 )< dp (20 ) and abs (x1 - x0 )> self . minzoom :
691
699
self .pos_x_rect_hor = x0
692
700
self .pos_y_rect_hor = y0
693
701
@@ -784,7 +792,7 @@ def blit(self, bbox=None):
784
792
rectangle:
785
793
(self.pos_x_rect_ver-dp(20), self.pos_y_rect_ver-dp(1), dp(40),dp(4))
786
794
787
- #horizontal rectangle right
795
+ #vertical rectangle top
788
796
Color:
789
797
rgba:0, 0, 0, self._alpha_ver
790
798
Line:
0 commit comments