@@ -1577,7 +1577,7 @@ class Cursor(AxesWidget):
15771577
15781578 Other Parameters
15791579 ----------------
1580- **lineprops
1580+ **props
15811581 `.Line2D` properties that control the appearance of the lines.
15821582 See also `~.Axes.axhline`.
15831583
@@ -1586,8 +1586,9 @@ class Cursor(AxesWidget):
15861586 See :doc:`/gallery/widgets/cursor`.
15871587 """
15881588
1589+ @_api .rename_parameter ("3.5" , "lineprops" , "props" )
15891590 def __init__ (self , ax , horizOn = True , vertOn = True , useblit = False ,
1590- ** lineprops ):
1591+ ** props ):
15911592 super ().__init__ (ax )
15921593
15931594 self .connect_event ('motion_notify_event' , self .onmove )
@@ -1599,9 +1600,9 @@ def __init__(self, ax, horizOn=True, vertOn=True, useblit=False,
15991600 self .useblit = useblit and self .canvas .supports_blit
16001601
16011602 if self .useblit :
1602- lineprops ['animated' ] = True
1603- self .lineh = ax .axhline (ax .get_ybound ()[0 ], visible = False , ** lineprops )
1604- self .linev = ax .axvline (ax .get_xbound ()[0 ], visible = False , ** lineprops )
1603+ props ['animated' ] = True
1604+ self .lineh = ax .axhline (ax .get_ybound ()[0 ], visible = False , ** props )
1605+ self .linev = ax .axvline (ax .get_xbound ()[0 ], visible = False , ** props )
16051606
16061607 self .background = None
16071608 self .needclear = False
@@ -1675,8 +1676,9 @@ class MultiCursor(Widget):
16751676 plt.show()
16761677
16771678 """
1679+ @_api .rename_parameter ("3.5" , "lineprops" , "props" )
16781680 def __init__ (self , canvas , axes , useblit = True , horizOn = False , vertOn = True ,
1679- ** lineprops ):
1681+ ** props ):
16801682
16811683 self .canvas = canvas
16821684 self .axes = axes
@@ -1694,16 +1696,16 @@ def __init__(self, canvas, axes, useblit=True, horizOn=False, vertOn=True,
16941696 self .needclear = False
16951697
16961698 if self .useblit :
1697- lineprops ['animated' ] = True
1699+ props ['animated' ] = True
16981700
16991701 if vertOn :
1700- self .vlines = [ax .axvline (xmid , visible = False , ** lineprops )
1702+ self .vlines = [ax .axvline (xmid , visible = False , ** props )
17011703 for ax in axes ]
17021704 else :
17031705 self .vlines = []
17041706
17051707 if horizOn :
1706- self .hlines = [ax .axhline (ymid , visible = False , ** lineprops )
1708+ self .hlines = [ax .axhline (ymid , visible = False , ** props )
17071709 for ax in axes ]
17081710 else :
17091711 self .hlines = []
@@ -2020,7 +2022,7 @@ def on_select(min: float, max: float) -> Any
20202022 If True, use the backend-dependent blitting features for faster
20212023 canvas updates.
20222024
2023- rectprops : dict, optional
2025+ props : dict, optional
20242026 Dictionary of `matplotlib.patches.Patch` properties.
20252027 Default:
20262028 ``dict(facecolor='red', alpha=0.5)``
@@ -2060,26 +2062,26 @@ def on_select(min: float, max: float) -> Any
20602062 >>> ax.plot([1, 2, 3], [10, 50, 100])
20612063 >>> def onselect(vmin, vmax):
20622064 ... print(vmin, vmax)
2063- >>> rectprops = dict(facecolor='blue', alpha=0.5)
20642065 >>> span = mwidgets.SpanSelector(ax, onselect, 'horizontal',
2065- ... rectprops=rectprops )
2066+ ... props=dict(facecolor='blue', alpha=0.5) )
20662067 >>> fig.show()
20672068
20682069 See also: :doc:`/gallery/widgets/span_selector`
20692070 """
20702071
2072+ @_api .rename_parameter ("3.5" , "rectprops" , "props" )
20712073 @_api .rename_parameter ("3.5" , "span_stays" , "interactive" )
20722074 def __init__ (self , ax , onselect , direction , minspan = 0 , useblit = False ,
2073- rectprops = None , onmove_callback = None , interactive = False ,
2075+ props = None , onmove_callback = None , interactive = False ,
20742076 button = None , handle_props = None , handle_grab_distance = 10 ,
20752077 drag_from_anywhere = False ):
20762078
20772079 super ().__init__ (ax , onselect , useblit = useblit , button = button )
20782080
2079- if rectprops is None :
2080- rectprops = dict (facecolor = 'red' , alpha = 0.5 )
2081+ if props is None :
2082+ props = dict (facecolor = 'red' , alpha = 0.5 )
20812083
2082- rectprops ['animated' ] = self .useblit
2084+ props ['animated' ] = self .useblit
20832085
20842086 self .direction = direction
20852087
@@ -2091,7 +2093,7 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
20912093 # but we maintain it until it is removed
20922094 self ._pressv = None
20932095
2094- self ._rectprops = rectprops
2096+ self ._props = props
20952097 self .onmove_callback = onmove_callback
20962098 self .minspan = minspan
20972099
@@ -2105,12 +2107,13 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
21052107 self .new_axes (ax )
21062108
21072109 # Setup handles
2108- props = dict (color = rectprops .get ('facecolor' , 'r' ))
2109- props .update (cbook .normalize_kwargs (handle_props , Line2D ._alias_map ))
2110+ _handle_props = dict (color = props .get ('facecolor' , 'r' ))
2111+ _handle_props .update (cbook .normalize_kwargs (handle_props ,
2112+ Line2D ._alias_map ))
21102113
21112114 if self ._interactive :
21122115 self ._edge_order = ['min' , 'max' ]
2113- self ._setup_edge_handle (props )
2116+ self ._setup_edge_handle (_handle_props )
21142117
21152118 self ._active_handle = None
21162119
@@ -2119,7 +2122,9 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
21192122
21202123 rect = _api .deprecate_privatize_attribute ("3.5" )
21212124
2122- rectprops = _api .deprecate_privatize_attribute ("3.5" )
2125+ rectprops = _api .deprecated ("3.5" )(
2126+ property (lambda self : self ._props )
2127+ )
21232128
21242129 active_handle = _api .deprecate_privatize_attribute ("3.5" )
21252130
@@ -2150,7 +2155,7 @@ def new_axes(self, ax):
21502155 self ._rect = Rectangle ((0 , 0 ), w , h ,
21512156 transform = trans ,
21522157 visible = False ,
2153- ** self ._rectprops )
2158+ ** self ._props )
21542159
21552160 self .ax .add_patch (self ._rect )
21562161 if len (self .artists ) > 0 :
@@ -2533,7 +2538,7 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
25332538 Whether to use blitting for faster drawing (if supported by the
25342539 backend).
25352540
2536- rectprops : dict, optional
2541+ props : dict, optional
25372542 Properties with which the __ARTIST_NAME__ is drawn.
25382543 Default:
25392544 ``dict(facecolor='red', edgecolor='black', alpha=0.2, fill=True))``
@@ -2593,9 +2598,9 @@ class RectangleSelector(_SelectorWidget):
25932598 >>> def onselect(eclick, erelease):
25942599 ... print(eclick.xdata, eclick.ydata)
25952600 ... print(erelease.xdata, erelease.ydata)
2596- >>> rectprops = dict(facecolor='blue', alpha=0.5)
2597- >>> rect = mwidgets.RectangleSelector(ax, onselect, rectprops=rectprops ,
2598- interactive=True )
2601+ >>> props = dict(facecolor='blue', alpha=0.5)
2602+ >>> rect = mwidgets.RectangleSelector(ax, onselect, interactive=True ,
2603+ props=props )
25992604 >>> fig.show()
26002605
26012606 See also: :doc:`/gallery/widgets/rectangle_selector`
@@ -2605,11 +2610,12 @@ class RectangleSelector(_SelectorWidget):
26052610
26062611 @_api .rename_parameter ("3.5" , "maxdist" , "handle_grab_distance" )
26072612 @_api .rename_parameter ("3.5" , "marker_props" , "handle_props" )
2613+ @_api .rename_parameter ("3.5" , "rectprops" , "props" )
26082614 @_api .delete_parameter ("3.5" , "drawtype" )
26092615 @_api .delete_parameter ("3.5" , "lineprops" )
26102616 def __init__ (self , ax , onselect , drawtype = 'box' ,
26112617 minspanx = 0 , minspany = 0 , useblit = False ,
2612- lineprops = None , rectprops = None , spancoords = 'data' ,
2618+ lineprops = None , props = None , spancoords = 'data' ,
26132619 button = None , handle_grab_distance = 10 , handle_props = None ,
26142620 interactive = False , state_modifier_keys = None ,
26152621 drag_from_anywhere = False ):
@@ -2626,19 +2632,19 @@ def __init__(self, ax, onselect, drawtype='box',
26262632 "3.5" , message = "Support for drawtype='none' is deprecated "
26272633 "since %(since)s and will be removed "
26282634 "%(removal)s."
2629- "Use rectprops =dict(visible=False) instead." )
2635+ "Use props =dict(visible=False) instead." )
26302636 drawtype = 'line'
26312637 self .visible = False
26322638
26332639 if drawtype == 'box' :
2634- if rectprops is None :
2635- rectprops = dict (facecolor = 'red' , edgecolor = 'black' ,
2636- alpha = 0.2 , fill = True )
2637- rectprops ['animated' ] = self .useblit
2638- _rectprops = rectprops
2639- self .visible = _rectprops .pop ('visible' , self .visible )
2640+ if props is None :
2641+ props = dict (facecolor = 'red' , edgecolor = 'black' ,
2642+ alpha = 0.2 , fill = True )
2643+ props ['animated' ] = self .useblit
2644+ _props = props
2645+ self .visible = _props .pop ('visible' , self .visible )
26402646 self ._to_draw = self ._shape_klass ((0 , 0 ), 0 , 1 , visible = False ,
2641- ** _rectprops )
2647+ ** _props )
26422648 self .ax .add_patch (self ._to_draw )
26432649 if drawtype == 'line' :
26442650 _api .warn_deprecated (
@@ -2663,25 +2669,27 @@ def __init__(self, ax, onselect, drawtype='box',
26632669
26642670 self .handle_grab_distance = handle_grab_distance
26652671
2666- if rectprops is None :
2667- props = dict (markeredgecolor = 'r' )
2672+ if props is None :
2673+ _handle_props = dict (markeredgecolor = 'r' )
26682674 else :
2669- props = dict (markeredgecolor = rectprops .get ('edgecolor' , 'r' ))
2670- props .update (cbook .normalize_kwargs (handle_props , Line2D ._alias_map ))
2675+ _handle_props = dict (markeredgecolor = props .get ('edgecolor' , 'r' ))
2676+ _handle_props .update (cbook .normalize_kwargs (handle_props ,
2677+ Line2D ._alias_map ))
26712678 self ._corner_order = ['NW' , 'NE' , 'SE' , 'SW' ]
26722679 xc , yc = self .corners
2673- self ._corner_handles = ToolHandles (self .ax , xc , yc , marker_props = props ,
2680+ self ._corner_handles = ToolHandles (self .ax , xc , yc ,
2681+ marker_props = _handle_props ,
26742682 useblit = self .useblit )
26752683
26762684 self ._edge_order = ['W' , 'N' , 'E' , 'S' ]
26772685 xe , ye = self .edge_centers
26782686 self ._edge_handles = ToolHandles (self .ax , xe , ye , marker = 's' ,
2679- marker_props = props ,
2687+ marker_props = _handle_props ,
26802688 useblit = self .useblit )
26812689
26822690 xc , yc = self .center
26832691 self ._center_handle = ToolHandles (self .ax , [xc ], [yc ], marker = 's' ,
2684- marker_props = props ,
2692+ marker_props = _handle_props ,
26852693 useblit = self .useblit )
26862694
26872695 self ._active_handle = None
@@ -3077,20 +3085,25 @@ def onselect(verts):
30773085 useblit : bool, default: True
30783086 Whether to use blitting for faster drawing (if supported by the
30793087 backend).
3088+ props : dict, optional
3089+ Properties with which the line is drawn.
3090+ Default:
3091+ ``dict()``
30803092 button : `.MouseButton` or list of `.MouseButton`, optional
30813093 The mouse buttons used for rectangle selection. Default is ``None``,
30823094 which corresponds to all buttons.
30833095 """
30843096
3085- def __init__ (self , ax , onselect = None , useblit = True , lineprops = None ,
3097+ @_api .rename_parameter ("3.5" , "lineprops" , "props" )
3098+ def __init__ (self , ax , onselect = None , useblit = True , props = None ,
30863099 button = None ):
30873100 super ().__init__ (ax , onselect , useblit = useblit , button = button )
30883101 self .verts = None
3089- if lineprops is None :
3090- lineprops = dict ()
3102+ if props is None :
3103+ props = dict ()
30913104 # self.useblit may be != useblit, if the canvas doesn't support blit.
3092- lineprops .update (animated = self .useblit , visible = False )
3093- self .line = Line2D ([], [], ** lineprops )
3105+ props .update (animated = self .useblit , visible = False )
3106+ self .line = Line2D ([], [], ** props )
30943107 self .ax .add_line (self .line )
30953108 self .artists = [self .line ]
30963109
@@ -3155,7 +3168,7 @@ class PolygonSelector(_SelectorWidget):
31553168 Whether to use blitting for faster drawing (if supported by the
31563169 backend).
31573170
3158- lineprops : dict, optional
3171+ props : dict, optional
31593172 Artist properties for the line representing the edges of the polygon.
31603173 Default:
31613174 dict(color='k', linestyle='-', linewidth=2, alpha=0.5)
@@ -3180,11 +3193,12 @@ class PolygonSelector(_SelectorWidget):
31803193 point.
31813194 """
31823195
3196+ @_api .rename_parameter ("3.5" , "lineprops" , "props" )
31833197 @_api .rename_parameter ("3.5" , "markerprops" , "handle_props" )
31843198 @_api .rename_parameter ("3.5" , "vertex_select_radius" ,
31853199 "handle_grab_distance" )
31863200 def __init__ (self , ax , onselect , useblit = False ,
3187- lineprops = None , handle_props = None , handle_grab_distance = 15 ):
3201+ props = None , handle_props = None , handle_grab_distance = 15 ):
31883202 # The state modifiers 'move', 'square', and 'center' are expected by
31893203 # _SelectorWidget but are not supported by PolygonSelector
31903204 # Note: could not use the existing 'move' state modifier in-place of
@@ -3200,15 +3214,15 @@ def __init__(self, ax, onselect, useblit=False,
32003214 self ._xs , self ._ys = [0 ], [0 ]
32013215 self ._polygon_completed = False
32023216
3203- if lineprops is None :
3204- lineprops = dict (color = 'k' , linestyle = '-' , linewidth = 2 , alpha = 0.5 )
3205- lineprops ['animated' ] = self .useblit
3206- self .line = Line2D (self ._xs , self ._ys , ** lineprops )
3217+ if props is None :
3218+ props = dict (color = 'k' , linestyle = '-' , linewidth = 2 , alpha = 0.5 )
3219+ props ['animated' ] = self .useblit
3220+ self .line = Line2D (self ._xs , self ._ys , ** props )
32073221 self .ax .add_line (self .line )
32083222
32093223 if handle_props is None :
32103224 handle_props = dict (markeredgecolor = 'k' ,
3211- markerfacecolor = lineprops .get ('color' , 'k' ))
3225+ markerfacecolor = props .get ('color' , 'k' ))
32123226 self ._polygon_handles = ToolHandles (self .ax , self ._xs , self ._ys ,
32133227 useblit = self .useblit ,
32143228 marker_props = handle_props )
0 commit comments