@@ -2457,15 +2457,16 @@ def artists(self):
2457
2457
2458
2458
def set_props (self , ** props ):
2459
2459
"""
2460
- Set the properties of the selector artist. See the `props` argument
2461
- in the selector docstring to know which properties are supported.
2460
+ Set the properties of the selector artist.
2461
+
2462
+ See the *props* argument in the selector docstring to know which properties are
2463
+ supported.
2462
2464
"""
2463
2465
artist = self ._selection_artist
2464
2466
props = cbook .normalize_kwargs (props , artist )
2465
2467
artist .set (** props )
2466
2468
if self .useblit :
2467
2469
self .update ()
2468
- self ._props .update (props )
2469
2470
2470
2471
def set_handle_props (self , ** handle_props ):
2471
2472
"""
@@ -2658,7 +2659,6 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
2658
2659
# but we maintain it until it is removed
2659
2660
self ._pressv = None
2660
2661
2661
- self ._props = props
2662
2662
self .onmove_callback = onmove_callback
2663
2663
self .minspan = minspan
2664
2664
@@ -2670,7 +2670,7 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
2670
2670
2671
2671
# Reset canvas so that `new_axes` connects events.
2672
2672
self .canvas = None
2673
- self .new_axes (ax )
2673
+ self .new_axes (ax , _props = props )
2674
2674
2675
2675
# Setup handles
2676
2676
self ._handle_props = {
@@ -2686,7 +2686,7 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
2686
2686
# prev attribute is deprecated but we still need to maintain it
2687
2687
self ._prev = (0 , 0 )
2688
2688
2689
- def new_axes (self , ax ):
2689
+ def new_axes (self , ax , * , _props = None ):
2690
2690
"""Set SpanSelector to operate on a new Axes."""
2691
2691
self .ax = ax
2692
2692
if self .canvas is not ax .figure .canvas :
@@ -2705,10 +2705,11 @@ def new_axes(self, ax):
2705
2705
else :
2706
2706
trans = ax .get_yaxis_transform ()
2707
2707
w , h = 1 , 0
2708
- rect_artist = Rectangle ((0 , 0 ), w , h ,
2709
- transform = trans ,
2710
- visible = False ,
2711
- ** self ._props )
2708
+ rect_artist = Rectangle ((0 , 0 ), w , h , transform = trans , visible = False )
2709
+ if _props is not None :
2710
+ rect_artist .update (_props )
2711
+ elif self ._selection_artist is not None :
2712
+ rect_artist .update_from (self ._selection_artist )
2712
2713
2713
2714
self .ax .add_patch (rect_artist )
2714
2715
self ._selection_artist = rect_artist
@@ -3287,9 +3288,9 @@ def __init__(self, ax, onselect, *, minspanx=0, minspany=0, useblit=False,
3287
3288
if props is None :
3288
3289
props = dict (facecolor = 'red' , edgecolor = 'black' ,
3289
3290
alpha = 0.2 , fill = True )
3290
- self . _props = {** props , 'animated' : self .useblit }
3291
- self ._visible = self . _props .pop ('visible' , self ._visible )
3292
- to_draw = self ._init_shape (** self . _props )
3291
+ props = {** props , 'animated' : self .useblit }
3292
+ self ._visible = props .pop ('visible' , self ._visible )
3293
+ to_draw = self ._init_shape (** props )
3293
3294
self .ax .add_patch (to_draw )
3294
3295
3295
3296
self ._selection_artist = to_draw
@@ -3305,8 +3306,7 @@ def __init__(self, ax, onselect, *, minspanx=0, minspany=0, useblit=False,
3305
3306
3306
3307
if self ._interactive :
3307
3308
self ._handle_props = {
3308
- 'markeredgecolor' : (self ._props or {}).get (
3309
- 'edgecolor' , 'black' ),
3309
+ 'markeredgecolor' : (props or {}).get ('edgecolor' , 'black' ),
3310
3310
** cbook .normalize_kwargs (handle_props , Line2D )}
3311
3311
3312
3312
self ._corner_order = ['SW' , 'SE' , 'NE' , 'NW' ]
@@ -3942,13 +3942,13 @@ def __init__(self, ax, onselect, useblit=False,
3942
3942
3943
3943
if props is None :
3944
3944
props = dict (color = 'k' , linestyle = '-' , linewidth = 2 , alpha = 0.5 )
3945
- self . _props = {** props , 'animated' : self .useblit }
3946
- self ._selection_artist = line = Line2D ([], [], ** self . _props )
3945
+ props = {** props , 'animated' : self .useblit }
3946
+ self ._selection_artist = line = Line2D ([], [], ** props )
3947
3947
self .ax .add_line (line )
3948
3948
3949
3949
if handle_props is None :
3950
3950
handle_props = dict (markeredgecolor = 'k' ,
3951
- markerfacecolor = self . _props .get ('color' , 'k' ))
3951
+ markerfacecolor = props .get ('color' , 'k' ))
3952
3952
self ._handle_props = handle_props
3953
3953
self ._polygon_handles = ToolHandles (self .ax , [], [],
3954
3954
useblit = self .useblit ,
0 commit comments