@@ -1992,15 +1992,15 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
19921992 _api .check_in_list (['horizontal' , 'vertical' ], direction = direction )
19931993 self ._direction = direction
19941994
1995- self .rect = None
1995+ self ._rect = None
19961996 self .visible = True
19971997 self ._extents_on_press = None
19981998
19991999 # self._pressv is deprecated and we don't use it internally anymore
20002000 # but we maintain it until it is removed
20012001 self ._pressv = None
20022002
2003- self .rectprops = rectprops
2003+ self ._rectprops = rectprops
20042004 self .onmove_callback = onmove_callback
20052005 self .minspan = minspan
20062006
@@ -2043,17 +2043,17 @@ def new_axes(self, ax):
20432043 else :
20442044 trans = ax .get_yaxis_transform ()
20452045 w , h = 1 , 0
2046- self .rect = Rectangle ((0 , 0 ), w , h ,
2047- transform = trans ,
2048- visible = False ,
2049- ** self .rectprops )
2046+ self ._rect = Rectangle ((0 , 0 ), w , h ,
2047+ transform = trans ,
2048+ visible = False ,
2049+ ** self ._rectprops )
20502050
2051- self .ax .add_patch (self .rect )
2052- self .artists = [self .rect ]
2051+ self .ax .add_patch (self ._rect )
2052+ self .artists = [self ._rect ]
20532053
20542054 def _press (self , event ):
20552055 """Button press event handler."""
2056- if self .interactive and self .rect .get_visible ():
2056+ if self .interactive and self ._rect .get_visible ():
20572057 self ._set_active_handle (event )
20582058 else :
20592059 self .active_handle = None
@@ -2072,6 +2072,11 @@ def _press(self, event):
20722072
20732073 return False
20742074
2075+ @_api .deprecated ("3.5" )
2076+ @property
2077+ def rect (self ):
2078+ return self ._rect
2079+
20752080 @_api .deprecated ("3.5" )
20762081 @property
20772082 def pressv (self ):
@@ -2082,6 +2087,11 @@ def pressv(self):
20822087 def pressv (self , value ):
20832088 self ._pressv = value
20842089
2090+ @_api .deprecated ("3.5" )
2091+ @property
2092+ def rectprops (self ):
2093+ return self ._rectprops
2094+
20852095 @property
20862096 def direction (self ):
20872097 """Direction of the span selector: 'vertical' or 'horizontal'."""
@@ -2090,7 +2100,7 @@ def direction(self):
20902100 def _release (self , event ):
20912101 """Button release event handler."""
20922102 if not self .interactive :
2093- self .rect .set_visible (False )
2103+ self ._rect .set_visible (False )
20942104
20952105 vmin , vmax = self .extents
20962106 span = vmax - vmin
@@ -2149,11 +2159,11 @@ def _draw_shape(self, vmin, vmax):
21492159 if vmin > vmax :
21502160 vmin , vmax = vmax , vmin
21512161 if self .direction == 'horizontal' :
2152- self .rect .set_x (vmin )
2153- self .rect .set_width (vmax - vmin )
2162+ self ._rect .set_x (vmin )
2163+ self ._rect .set_width (vmax - vmin )
21542164 else :
2155- self .rect .set_y (vmin )
2156- self .rect .set_height (vmax - vmin )
2165+ self ._rect .set_y (vmin )
2166+ self ._rect .set_height (vmax - vmin )
21572167
21582168 def _set_active_handle (self , event ):
21592169 """Set active handle based on the location of the mouse event."""
@@ -2183,24 +2193,24 @@ def _set_active_handle(self, event):
21832193
21842194 def _contains (self , event ):
21852195 """Return True if event is within the patch."""
2186- return self .rect .contains (event , radius = 0 )[0 ]
2196+ return self ._rect .contains (event , radius = 0 )[0 ]
21872197
21882198 @property
21892199 def vmin (self ):
21902200 """Get the start span coordinate."""
21912201 if self .direction == 'horizontal' :
2192- vmin = self .rect .get_x ()
2202+ vmin = self ._rect .get_x ()
21932203 else :
2194- vmin = self .rect .get_y ()
2204+ vmin = self ._rect .get_y ()
21952205 return vmin
21962206
21972207 @property
21982208 def vmax (self ):
21992209 """Get the end span coordinate."""
22002210 if self .direction == 'horizontal' :
2201- vmax = self .vmin + self .rect .get_width ()
2211+ vmax = self .vmin + self ._rect .get_width ()
22022212 else :
2203- vmax = self .vmin + self .rect .get_height ()
2213+ vmax = self .vmin + self ._rect .get_height ()
22042214 return vmax
22052215
22062216 @property
@@ -2470,7 +2480,7 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
24702480 super ().__init__ (ax , onselect , useblit = useblit , button = button ,
24712481 state_modifier_keys = state_modifier_keys )
24722482
2473- self .to_draw = None
2483+ self ._to_draw = None
24742484 self .visible = True
24752485 self .interactive = interactive
24762486 self .drag_from_anywhere = drag_from_anywhere
@@ -2489,11 +2499,11 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
24892499 rectprops = dict (facecolor = 'red' , edgecolor = 'black' ,
24902500 alpha = 0.2 , fill = True )
24912501 rectprops ['animated' ] = self .useblit
2492- self . rectprops = rectprops
2493- self .visible = self . rectprops .pop ('visible' , self .visible )
2494- self .to_draw = self ._shape_klass ((0 , 0 ), 0 , 1 , visible = False ,
2495- ** self . rectprops )
2496- self .ax .add_patch (self .to_draw )
2502+ _rectprops = rectprops
2503+ self .visible = _rectprops .pop ('visible' , self .visible )
2504+ self ._to_draw = self ._shape_klass ((0 , 0 ), 0 , 1 , visible = False ,
2505+ ** _rectprops )
2506+ self .ax .add_patch (self ._to_draw )
24972507 if drawtype == 'line' :
24982508 _api .warn_deprecated (
24992509 "3.5" , message = "Support for drawtype='line' is deprecated "
@@ -2504,9 +2514,9 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
25042514 linewidth = 2 , alpha = 0.5 )
25052515 lineprops ['animated' ] = self .useblit
25062516 self .lineprops = lineprops
2507- self .to_draw = Line2D ([0 , 0 ], [0 , 0 ], visible = False ,
2508- ** self .lineprops )
2509- self .ax .add_line (self .to_draw )
2517+ self ._to_draw = Line2D ([0 , 0 ], [0 , 0 ], visible = False ,
2518+ ** self .lineprops )
2519+ self .ax .add_line (self ._to_draw )
25102520
25112521 self .minspanx = minspanx
25122522 self .minspany = minspany
@@ -2540,20 +2550,25 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
25402550
25412551 self .active_handle = None
25422552
2543- self .artists = [self .to_draw , self ._center_handle .artist ,
2553+ self .artists = [self ._to_draw , self ._center_handle .artist ,
25442554 self ._corner_handles .artist ,
25452555 self ._edge_handles .artist ]
25462556
25472557 if not self .interactive :
2548- self .artists = [self .to_draw ]
2558+ self .artists = [self ._to_draw ]
25492559
25502560 self ._extents_on_press = None
25512561
2562+ @_api .deprecated ("3.5" )
2563+ @property
2564+ def to_draw (self ):
2565+ return self ._to_draw
2566+
25522567 def _press (self , event ):
25532568 """Button press event handler."""
25542569 # make the drawn box/line visible get the click-coordinates,
25552570 # button, ...
2556- if self .interactive and self .to_draw .get_visible ():
2571+ if self .interactive and self ._to_draw .get_visible ():
25572572 self ._set_active_handle (event )
25582573 else :
25592574 self .active_handle = None
@@ -2572,7 +2587,7 @@ def _press(self, event):
25722587 def _release (self , event ):
25732588 """Button release event handler."""
25742589 if not self .interactive :
2575- self .to_draw .set_visible (False )
2590+ self ._to_draw .set_visible (False )
25762591
25772592 # update the eventpress and eventrelease with the resulting extents
25782593 x0 , x1 , y0 , y1 = self .extents
@@ -2671,13 +2686,13 @@ def _onmove(self, event):
26712686 @property
26722687 def _rect_bbox (self ):
26732688 if self .drawtype == 'box' :
2674- x0 = self .to_draw .get_x ()
2675- y0 = self .to_draw .get_y ()
2676- width = self .to_draw .get_width ()
2677- height = self .to_draw .get_height ()
2689+ x0 = self ._to_draw .get_x ()
2690+ y0 = self ._to_draw .get_y ()
2691+ width = self ._to_draw .get_width ()
2692+ height = self ._to_draw .get_height ()
26782693 return x0 , y0 , width , height
26792694 else :
2680- x , y = self .to_draw .get_data ()
2695+ x , y = self ._to_draw .get_data ()
26812696 x0 , x1 = min (x ), max (x )
26822697 y0 , y1 = min (y ), max (y )
26832698 return x0 , y0 , x1 - x0 , y1 - y0
@@ -2740,13 +2755,13 @@ def _draw_shape(self, extents):
27402755 ymax = min (ymax , ylim [1 ])
27412756
27422757 if self .drawtype == 'box' :
2743- self .to_draw .set_x (xmin )
2744- self .to_draw .set_y (ymin )
2745- self .to_draw .set_width (xmax - xmin )
2746- self .to_draw .set_height (ymax - ymin )
2758+ self ._to_draw .set_x (xmin )
2759+ self ._to_draw .set_y (ymin )
2760+ self ._to_draw .set_width (xmax - xmin )
2761+ self ._to_draw .set_height (ymax - ymin )
27472762
27482763 elif self .drawtype == 'line' :
2749- self .to_draw .set_data ([xmin , xmax ], [ymin , ymax ])
2764+ self ._to_draw .set_data ([xmin , xmax ], [ymin , ymax ])
27502765
27512766 def _set_active_handle (self , event ):
27522767 """Set active handle based on the location of the mouse event."""
@@ -2789,7 +2804,7 @@ def _set_active_handle(self, event):
27892804
27902805 def _contains (self , event ):
27912806 """Return True if event is within the patch."""
2792- return self .to_draw .contains (event , radius = 0 )[0 ]
2807+ return self ._to_draw .contains (event , radius = 0 )[0 ]
27932808
27942809 @property
27952810 def geometry (self ):
@@ -2800,12 +2815,12 @@ def geometry(self):
28002815 of the four corners of the rectangle starting and ending
28012816 in the top left corner.
28022817 """
2803- if hasattr (self .to_draw , 'get_verts' ):
2818+ if hasattr (self ._to_draw , 'get_verts' ):
28042819 xfm = self .ax .transData .inverted ()
2805- y , x = xfm .transform (self .to_draw .get_verts ()).T
2820+ y , x = xfm .transform (self ._to_draw .get_verts ()).T
28062821 return np .array ([x , y ])
28072822 else :
2808- return np .array (self .to_draw .get_data ())
2823+ return np .array (self ._to_draw .get_data ())
28092824
28102825
28112826class EllipseSelector (RectangleSelector ):
@@ -2856,24 +2871,24 @@ def _draw_shape(self, extents):
28562871 b = (ymax - ymin ) / 2.
28572872
28582873 if self .drawtype == 'box' :
2859- self .to_draw .center = center
2860- self .to_draw .width = 2 * a
2861- self .to_draw .height = 2 * b
2874+ self ._to_draw .center = center
2875+ self ._to_draw .width = 2 * a
2876+ self ._to_draw .height = 2 * b
28622877 else :
28632878 rad = np .deg2rad (np .arange (31 ) * 12 )
28642879 x = a * np .cos (rad ) + center [0 ]
28652880 y = b * np .sin (rad ) + center [1 ]
2866- self .to_draw .set_data (x , y )
2881+ self ._to_draw .set_data (x , y )
28672882
28682883 @property
28692884 def _rect_bbox (self ):
28702885 if self .drawtype == 'box' :
2871- x , y = self .to_draw .center
2872- width = self .to_draw .width
2873- height = self .to_draw .height
2886+ x , y = self ._to_draw .center
2887+ width = self ._to_draw .width
2888+ height = self ._to_draw .height
28742889 return x - width / 2. , y - height / 2. , width , height
28752890 else :
2876- x , y = self .to_draw .get_data ()
2891+ x , y = self ._to_draw .get_data ()
28772892 x0 , x1 = min (x ), max (x )
28782893 y0 , y1 = min (y ), max (y )
28792894 return x0 , y0 , x1 - x0 , y1 - y0
0 commit comments