@@ -1449,7 +1449,7 @@ class Cursor(AxesWidget):
14491449
14501450 Other Parameters
14511451 ----------------
1452- **lineprops
1452+ **props
14531453 `.Line2D` properties that control the appearance of the lines.
14541454 See also `~.Axes.axhline`.
14551455
@@ -1458,8 +1458,9 @@ class Cursor(AxesWidget):
14581458 See :doc:`/gallery/widgets/cursor`.
14591459 """
14601460
1461+ @_api .rename_parameter ("3.5" , "lineprops" , "props" )
14611462 def __init__ (self , ax , horizOn = True , vertOn = True , useblit = False ,
1462- ** lineprops ):
1463+ ** props ):
14631464 super ().__init__ (ax )
14641465
14651466 self .connect_event ('motion_notify_event' , self .onmove )
@@ -1471,9 +1472,9 @@ def __init__(self, ax, horizOn=True, vertOn=True, useblit=False,
14711472 self .useblit = useblit and self .canvas .supports_blit
14721473
14731474 if self .useblit :
1474- lineprops ['animated' ] = True
1475- self .lineh = ax .axhline (ax .get_ybound ()[0 ], visible = False , ** lineprops )
1476- self .linev = ax .axvline (ax .get_xbound ()[0 ], visible = False , ** lineprops )
1475+ props ['animated' ] = True
1476+ self .lineh = ax .axhline (ax .get_ybound ()[0 ], visible = False , ** props )
1477+ self .linev = ax .axvline (ax .get_xbound ()[0 ], visible = False , ** props )
14771478
14781479 self .background = None
14791480 self .needclear = False
@@ -1547,8 +1548,9 @@ class MultiCursor(Widget):
15471548 plt.show()
15481549
15491550 """
1551+ @_api .rename_parameter ("3.5" , "lineprops" , "props" )
15501552 def __init__ (self , canvas , axes , useblit = True , horizOn = False , vertOn = True ,
1551- ** lineprops ):
1553+ ** props ):
15521554
15531555 self .canvas = canvas
15541556 self .axes = axes
@@ -1566,16 +1568,16 @@ def __init__(self, canvas, axes, useblit=True, horizOn=False, vertOn=True,
15661568 self .needclear = False
15671569
15681570 if self .useblit :
1569- lineprops ['animated' ] = True
1571+ props ['animated' ] = True
15701572
15711573 if vertOn :
1572- self .vlines = [ax .axvline (xmid , visible = False , ** lineprops )
1574+ self .vlines = [ax .axvline (xmid , visible = False , ** props )
15731575 for ax in axes ]
15741576 else :
15751577 self .vlines = []
15761578
15771579 if horizOn :
1578- self .hlines = [ax .axhline (ymid , visible = False , ** lineprops )
1580+ self .hlines = [ax .axhline (ymid , visible = False , ** props )
15791581 for ax in axes ]
15801582 else :
15811583 self .hlines = []
@@ -1888,7 +1890,7 @@ def on_select(min: float, max: float) -> Any
18881890 If True, use the backend-dependent blitting features for faster
18891891 canvas updates.
18901892
1891- rectprops : dict, optional
1893+ props : dict, optional
18921894 Dictionary of `matplotlib.patches.Patch` properties.
18931895 Default:
18941896 ``dict(facecolor='red', alpha=0.5)``
@@ -1928,26 +1930,26 @@ def on_select(min: float, max: float) -> Any
19281930 >>> ax.plot([1, 2, 3], [10, 50, 100])
19291931 >>> def onselect(vmin, vmax):
19301932 ... print(vmin, vmax)
1931- >>> rectprops = dict(facecolor='blue', alpha=0.5)
19321933 >>> span = mwidgets.SpanSelector(ax, onselect, 'horizontal',
1933- ... rectprops=rectprops )
1934+ ... props=dict(facecolor='blue', alpha=0.5) )
19341935 >>> fig.show()
19351936
19361937 See also: :doc:`/gallery/widgets/span_selector`
19371938 """
19381939
1940+ @_api .rename_parameter ("3.5" , "rectprops" , "props" )
19391941 @_api .rename_parameter ("3.5" , "span_stays" , "interactive" )
19401942 def __init__ (self , ax , onselect , direction , minspan = 0 , useblit = False ,
1941- rectprops = None , onmove_callback = None , interactive = False ,
1943+ props = None , onmove_callback = None , interactive = False ,
19421944 button = None , handle_props = None , handle_grab_distance = 10 ,
19431945 drag_from_anywhere = False ):
19441946
19451947 super ().__init__ (ax , onselect , useblit = useblit , button = button )
19461948
1947- if rectprops is None :
1948- rectprops = dict (facecolor = 'red' , alpha = 0.5 )
1949+ if props is None :
1950+ props = dict (facecolor = 'red' , alpha = 0.5 )
19491951
1950- rectprops ['animated' ] = self .useblit
1952+ props ['animated' ] = self .useblit
19511953
19521954 self .direction = direction
19531955
@@ -1959,7 +1961,7 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
19591961 # but we maintain it until it is removed
19601962 self ._pressv = None
19611963
1962- self ._rectprops = rectprops
1964+ self ._props = props
19631965 self .onmove_callback = onmove_callback
19641966 self .minspan = minspan
19651967
@@ -1973,12 +1975,13 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
19731975 self .new_axes (ax )
19741976
19751977 # Setup handles
1976- props = dict (color = rectprops .get ('facecolor' , 'r' ))
1977- props .update (cbook .normalize_kwargs (handle_props , Line2D ._alias_map ))
1978+ _handle_props = dict (color = props .get ('facecolor' , 'r' ))
1979+ _handle_props .update (cbook .normalize_kwargs (handle_props ,
1980+ Line2D ._alias_map ))
19781981
19791982 if self ._interactive :
19801983 self ._edge_order = ['min' , 'max' ]
1981- self ._setup_edge_handle (props )
1984+ self ._setup_edge_handle (_handle_props )
19821985
19831986 self ._active_handle = None
19841987
@@ -1987,7 +1990,9 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
19871990
19881991 rect = _api .deprecate_privatize_attribute ("3.5" )
19891992
1990- rectprops = _api .deprecate_privatize_attribute ("3.5" )
1993+ rectprops = _api .deprecated ("3.5" )(
1994+ property (lambda self : self ._props )
1995+ )
19911996
19921997 active_handle = _api .deprecate_privatize_attribute ("3.5" )
19931998
@@ -2018,7 +2023,7 @@ def new_axes(self, ax):
20182023 self ._rect = Rectangle ((0 , 0 ), w , h ,
20192024 transform = trans ,
20202025 visible = False ,
2021- ** self ._rectprops )
2026+ ** self ._props )
20222027
20232028 self .ax .add_patch (self ._rect )
20242029 if len (self .artists ) > 0 :
@@ -2401,7 +2406,7 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
24012406 Whether to use blitting for faster drawing (if supported by the
24022407 backend).
24032408
2404- rectprops : dict, optional
2409+ props : dict, optional
24052410 Properties with which the __ARTIST_NAME__ is drawn.
24062411 Default:
24072412 ``dict(facecolor='red', edgecolor='black', alpha=0.2, fill=True))``
@@ -2461,9 +2466,9 @@ class RectangleSelector(_SelectorWidget):
24612466 >>> def onselect(eclick, erelease):
24622467 ... print(eclick.xdata, eclick.ydata)
24632468 ... print(erelease.xdata, erelease.ydata)
2464- >>> rectprops = dict(facecolor='blue', alpha=0.5)
2465- >>> rect = mwidgets.RectangleSelector(ax, onselect, rectprops=rectprops ,
2466- interactive=True )
2469+ >>> props = dict(facecolor='blue', alpha=0.5)
2470+ >>> rect = mwidgets.RectangleSelector(ax, onselect, interactive=True ,
2471+ props=props )
24672472 >>> fig.show()
24682473
24692474 See also: :doc:`/gallery/widgets/rectangle_selector`
@@ -2473,11 +2478,12 @@ class RectangleSelector(_SelectorWidget):
24732478
24742479 @_api .rename_parameter ("3.5" , "maxdist" , "handle_grab_distance" )
24752480 @_api .rename_parameter ("3.5" , "marker_props" , "handle_props" )
2481+ @_api .rename_parameter ("3.5" , "rectprops" , "props" )
24762482 @_api .delete_parameter ("3.5" , "drawtype" )
24772483 @_api .delete_parameter ("3.5" , "lineprops" )
24782484 def __init__ (self , ax , onselect , drawtype = 'box' ,
24792485 minspanx = 0 , minspany = 0 , useblit = False ,
2480- lineprops = None , rectprops = None , spancoords = 'data' ,
2486+ lineprops = None , props = None , spancoords = 'data' ,
24812487 button = None , handle_grab_distance = 10 , handle_props = None ,
24822488 interactive = False , state_modifier_keys = None ,
24832489 drag_from_anywhere = False ):
@@ -2494,19 +2500,19 @@ def __init__(self, ax, onselect, drawtype='box',
24942500 "3.5" , message = "Support for drawtype='none' is deprecated "
24952501 "since %(since)s and will be removed "
24962502 "%(removal)s."
2497- "Use rectprops =dict(visible=False) instead." )
2503+ "Use props =dict(visible=False) instead." )
24982504 drawtype = 'line'
24992505 self .visible = False
25002506
25012507 if drawtype == 'box' :
2502- if rectprops is None :
2503- rectprops = dict (facecolor = 'red' , edgecolor = 'black' ,
2504- alpha = 0.2 , fill = True )
2505- rectprops ['animated' ] = self .useblit
2506- _rectprops = rectprops
2507- self .visible = _rectprops .pop ('visible' , self .visible )
2508+ if props is None :
2509+ props = dict (facecolor = 'red' , edgecolor = 'black' ,
2510+ alpha = 0.2 , fill = True )
2511+ props ['animated' ] = self .useblit
2512+ _props = props
2513+ self .visible = _props .pop ('visible' , self .visible )
25082514 self ._to_draw = self ._shape_klass ((0 , 0 ), 0 , 1 , visible = False ,
2509- ** _rectprops )
2515+ ** _props )
25102516 self .ax .add_patch (self ._to_draw )
25112517 if drawtype == 'line' :
25122518 _api .warn_deprecated (
@@ -2531,25 +2537,27 @@ def __init__(self, ax, onselect, drawtype='box',
25312537
25322538 self .handle_grab_distance = handle_grab_distance
25332539
2534- if rectprops is None :
2535- props = dict (markeredgecolor = 'r' )
2540+ if props is None :
2541+ _handle_props = dict (markeredgecolor = 'r' )
25362542 else :
2537- props = dict (markeredgecolor = rectprops .get ('edgecolor' , 'r' ))
2538- props .update (cbook .normalize_kwargs (handle_props , Line2D ._alias_map ))
2543+ _handle_props = dict (markeredgecolor = props .get ('edgecolor' , 'r' ))
2544+ _handle_props .update (cbook .normalize_kwargs (handle_props ,
2545+ Line2D ._alias_map ))
25392546 self ._corner_order = ['NW' , 'NE' , 'SE' , 'SW' ]
25402547 xc , yc = self .corners
2541- self ._corner_handles = ToolHandles (self .ax , xc , yc , marker_props = props ,
2548+ self ._corner_handles = ToolHandles (self .ax , xc , yc ,
2549+ marker_props = _handle_props ,
25422550 useblit = self .useblit )
25432551
25442552 self ._edge_order = ['W' , 'N' , 'E' , 'S' ]
25452553 xe , ye = self .edge_centers
25462554 self ._edge_handles = ToolHandles (self .ax , xe , ye , marker = 's' ,
2547- marker_props = props ,
2555+ marker_props = _handle_props ,
25482556 useblit = self .useblit )
25492557
25502558 xc , yc = self .center
25512559 self ._center_handle = ToolHandles (self .ax , [xc ], [yc ], marker = 's' ,
2552- marker_props = props ,
2560+ marker_props = _handle_props ,
25532561 useblit = self .useblit )
25542562
25552563 self ._active_handle = None
@@ -2945,20 +2953,25 @@ def onselect(verts):
29452953 useblit : bool, default: True
29462954 Whether to use blitting for faster drawing (if supported by the
29472955 backend).
2956+ props : dict, optional
2957+ Properties with which the line is drawn.
2958+ Default:
2959+ ``dict()``
29482960 button : `.MouseButton` or list of `.MouseButton`, optional
29492961 The mouse buttons used for rectangle selection. Default is ``None``,
29502962 which corresponds to all buttons.
29512963 """
29522964
2953- def __init__ (self , ax , onselect = None , useblit = True , lineprops = None ,
2965+ @_api .rename_parameter ("3.5" , "lineprops" , "props" )
2966+ def __init__ (self , ax , onselect = None , useblit = True , props = None ,
29542967 button = None ):
29552968 super ().__init__ (ax , onselect , useblit = useblit , button = button )
29562969 self .verts = None
2957- if lineprops is None :
2958- lineprops = dict ()
2970+ if props is None :
2971+ props = dict ()
29592972 # self.useblit may be != useblit, if the canvas doesn't support blit.
2960- lineprops .update (animated = self .useblit , visible = False )
2961- self .line = Line2D ([], [], ** lineprops )
2973+ props .update (animated = self .useblit , visible = False )
2974+ self .line = Line2D ([], [], ** props )
29622975 self .ax .add_line (self .line )
29632976 self .artists = [self .line ]
29642977
@@ -3023,7 +3036,7 @@ class PolygonSelector(_SelectorWidget):
30233036 Whether to use blitting for faster drawing (if supported by the
30243037 backend).
30253038
3026- lineprops : dict, optional
3039+ props : dict, optional
30273040 Artist properties for the line representing the edges of the polygon.
30283041 Default:
30293042 dict(color='k', linestyle='-', linewidth=2, alpha=0.5)
@@ -3048,11 +3061,12 @@ class PolygonSelector(_SelectorWidget):
30483061 point.
30493062 """
30503063
3064+ @_api .rename_parameter ("3.5" , "lineprops" , "props" )
30513065 @_api .rename_parameter ("3.5" , "markerprops" , "handle_props" )
30523066 @_api .rename_parameter ("3.5" , "vertex_select_radius" ,
30533067 "handle_grab_distance" )
30543068 def __init__ (self , ax , onselect , useblit = False ,
3055- lineprops = None , handle_props = None , handle_grab_distance = 15 ):
3069+ props = None , handle_props = None , handle_grab_distance = 15 ):
30563070 # The state modifiers 'move', 'square', and 'center' are expected by
30573071 # _SelectorWidget but are not supported by PolygonSelector
30583072 # Note: could not use the existing 'move' state modifier in-place of
@@ -3068,15 +3082,15 @@ def __init__(self, ax, onselect, useblit=False,
30683082 self ._xs , self ._ys = [0 ], [0 ]
30693083 self ._polygon_completed = False
30703084
3071- if lineprops is None :
3072- lineprops = dict (color = 'k' , linestyle = '-' , linewidth = 2 , alpha = 0.5 )
3073- lineprops ['animated' ] = self .useblit
3074- self .line = Line2D (self ._xs , self ._ys , ** lineprops )
3085+ if props is None :
3086+ props = dict (color = 'k' , linestyle = '-' , linewidth = 2 , alpha = 0.5 )
3087+ props ['animated' ] = self .useblit
3088+ self .line = Line2D (self ._xs , self ._ys , ** props )
30753089 self .ax .add_line (self .line )
30763090
30773091 if handle_props is None :
30783092 handle_props = dict (markeredgecolor = 'k' ,
3079- markerfacecolor = lineprops .get ('color' , 'k' ))
3093+ markerfacecolor = props .get ('color' , 'k' ))
30803094 self ._polygon_handles = ToolHandles (self .ax , self ._xs , self ._ys ,
30813095 useblit = self .useblit ,
30823096 marker_props = handle_props )
0 commit comments