@@ -259,7 +259,7 @@ def __init__(self, Q, X, Y, U, label,
259259 self .color = color
260260 self .label = label
261261 self ._labelsep_inches = labelsep
262- self .labelsep = (self ._labelsep_inches * Q .ax .figure .dpi )
262+ self .labelsep = (self ._labelsep_inches * Q .axes .figure .dpi )
263263
264264 # try to prevent closure over the real self
265265 weak_self = weakref .ref (self )
@@ -272,8 +272,8 @@ def on_dpi_change(fig):
272272 # the start of draw.
273273 self_weakref ._initialized = False
274274
275- self ._cid = Q .ax .figure .callbacks .connect ('dpi_changed' ,
276- on_dpi_change )
275+ self ._cid = Q .axes .figure .callbacks .connect (
276+ 'dpi_changed' , on_dpi_change )
277277
278278 self .labelpos = labelpos
279279 self .labelcolor = labelcolor
@@ -293,13 +293,10 @@ def on_dpi_change(fig):
293293 self .zorder = Q .zorder + 0.1
294294
295295 def remove (self ):
296- """
297- Overload the remove method
298- """
299- self .Q .ax .figure .callbacks .disconnect (self ._cid )
296+ # docstring inherited
297+ self .Q .axes .figure .callbacks .disconnect (self ._cid )
300298 self ._cid = None
301- # pass the remove call up the stack
302- martist .Artist .remove (self )
299+ super ().remove () # pass the remove call up the stack
303300
304301 def _init (self ):
305302 if True : # not self._initialized:
@@ -358,16 +355,12 @@ def draw(self, renderer):
358355 self .stale = False
359356
360357 def _set_transform (self ):
361- if self .coord == 'data' :
362- self .set_transform (self .Q .ax .transData )
363- elif self .coord == 'axes' :
364- self .set_transform (self .Q .ax .transAxes )
365- elif self .coord == 'figure' :
366- self .set_transform (self .Q .ax .figure .transFigure )
367- elif self .coord == 'inches' :
368- self .set_transform (self .Q .ax .figure .dpi_scale_trans )
369- else :
370- raise ValueError ('unrecognized coordinates' )
358+ self .set_transform (cbook ._check_getitem ({
359+ "data" : self .Q .axes .transData ,
360+ "axes" : self .Q .axes .transAxes ,
361+ "figure" : self .Q .axes .figure .transFigure ,
362+ "inches" : self .Q .axes .figure .dpi_scale_trans ,
363+ }, coordinates = self .coord ))
371364
372365 def set_figure (self , fig ):
373366 martist .Artist .set_figure (self , fig )
@@ -480,7 +473,7 @@ def __init__(self, ax, *args,
480473 by the following pyplot interface documentation:
481474 %s
482475 """
483- self .ax = ax
476+ self ._axes = ax # The attr actually set by the Artist.axes property.
484477 X , Y , U , V , C = _parse_args (* args , caller_name = 'quiver()' )
485478 self .X = X
486479 self .Y = Y
@@ -513,8 +506,7 @@ def __init__(self, ax, *args,
513506 self .set_UVC (U , V , C )
514507 self ._initialized = False
515508
516- # try to prevent closure over the real self
517- weak_self = weakref .ref (self )
509+ weak_self = weakref .ref (self ) # Prevent closure over the real self.
518510
519511 def on_dpi_change (fig ):
520512 self_weakref = weak_self ()
@@ -525,18 +517,17 @@ def on_dpi_change(fig):
525517 # the start of draw.
526518 self_weakref ._initialized = False
527519
528- self ._cid = self .ax .figure .callbacks .connect ('dpi_changed' ,
529- on_dpi_change )
520+ self ._cid = ax .figure .callbacks .connect ('dpi_changed' , on_dpi_change )
521+
522+ @cbook .deprecated ("3.3" , alternative = "axes" )
523+ def ax (self ):
524+ return self .axes
530525
531526 def remove (self ):
532- """
533- Overload the remove method
534- """
535- # disconnect the call back
536- self .ax .figure .callbacks .disconnect (self ._cid )
527+ # docstring inherited
528+ self .axes .figure .callbacks .disconnect (self ._cid )
537529 self ._cid = None
538- # pass the remove call up the stack
539- mcollections .PolyCollection .remove (self )
530+ super ().remove () # pass the remove call up the stack
540531
541532 def _init (self ):
542533 """
@@ -547,8 +538,7 @@ def _init(self):
547538 # available to have this work on an as-needed basis at present.
548539 if True : # not self._initialized:
549540 trans = self ._set_transform ()
550- ax = self .ax
551- self .span = trans .inverted ().transform_bbox (ax .bbox ).width
541+ self .span = trans .inverted ().transform_bbox (self .axes .bbox ).width
552542 if self .width is None :
553543 sn = np .clip (math .sqrt (self .N ), 8 , 25 )
554544 self .width = 0.06 * self .span / sn
@@ -609,31 +599,30 @@ def _dots_per_unit(self, units):
609599 """
610600 Return a scale factor for converting from units to pixels
611601 """
612- ax = self .ax
613602 if units in ('x' , 'y' , 'xy' ):
614603 if units == 'x' :
615- dx0 = ax .viewLim .width
616- dx1 = ax .bbox .width
604+ dx0 = self . axes .viewLim .width
605+ dx1 = self . axes .bbox .width
617606 elif units == 'y' :
618- dx0 = ax .viewLim .height
619- dx1 = ax .bbox .height
607+ dx0 = self . axes .viewLim .height
608+ dx1 = self . axes .bbox .height
620609 else : # 'xy' is assumed
621- dxx0 = ax .viewLim .width
622- dxx1 = ax .bbox .width
623- dyy0 = ax .viewLim .height
624- dyy1 = ax .bbox .height
610+ dxx0 = self . axes .viewLim .width
611+ dxx1 = self . axes .bbox .width
612+ dyy0 = self . axes .viewLim .height
613+ dyy1 = self . axes .bbox .height
625614 dx1 = np .hypot (dxx1 , dyy1 )
626615 dx0 = np .hypot (dxx0 , dyy0 )
627616 dx = dx1 / dx0
628617 else :
629618 if units == 'width' :
630- dx = ax .bbox .width
619+ dx = self . axes .bbox .width
631620 elif units == 'height' :
632- dx = ax .bbox .height
621+ dx = self . axes .bbox .height
633622 elif units == 'dots' :
634623 dx = 1.0
635624 elif units == 'inches' :
636- dx = ax .figure .dpi
625+ dx = self . axes .figure .dpi
637626 else :
638627 raise ValueError ('unrecognized units' )
639628 return dx
@@ -650,9 +639,9 @@ def _set_transform(self):
650639 return trans
651640
652641 def _angles_lengths (self , U , V , eps = 1 ):
653- xy = self .ax .transData .transform (self .XY )
642+ xy = self .axes .transData .transform (self .XY )
654643 uv = np .column_stack ((U , V ))
655- xyp = self .ax .transData .transform (self .XY + eps * uv )
644+ xyp = self .axes .transData .transform (self .XY + eps * uv )
656645 dxy = xyp - xy
657646 angles = np .arctan2 (dxy [:, 1 ], dxy [:, 0 ])
658647 lengths = np .hypot (* dxy .T ) / eps
@@ -670,7 +659,7 @@ def _make_verts(self, U, V, angles):
670659 # Calculate eps based on the extents of the plot
671660 # so that we don't end up with roundoff error from
672661 # adding a small number to a large.
673- eps = np .abs (self .ax .dataLim .extents ).max () * 0.001
662+ eps = np .abs (self .axes .dataLim .extents ).max () * 0.001
674663 angles , lengths = self ._angles_lengths (U , V , eps = eps )
675664 if str_angles and self .scale_units == 'xy' :
676665 a = lengths
@@ -806,7 +795,6 @@ def _h_arrows(self, length):
806795 : / \ \ \
807796 : ------------------------------
808797
809-
810798The largest increment is given by a triangle (or "flag"). After those
811799come full lines (barbs). The smallest increment is a half line. There
812800is only, of course, ever at most 1 half line. If the magnitude is
@@ -818,8 +806,6 @@ def _h_arrows(self, length):
818806
819807See also https://en.wikipedia.org/wiki/Wind_barb.
820808
821-
822-
823809Parameters
824810----------
825811X, Y : 1D or 2D array-like, optional
0 commit comments