@@ -315,7 +315,7 @@ def set_label_props(self, label, text, color):
315
315
label .set_text (text )
316
316
label .set_color (color )
317
317
label .set_fontproperties (self .labelFontProps )
318
- label .set_clip_box (self .ax .bbox )
318
+ label .set_clip_box (self .axes .bbox )
319
319
320
320
def get_text (self , lev , fmt ):
321
321
"""Get the text of the label."""
@@ -457,7 +457,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
457
457
return rotation , nlc
458
458
459
459
def _get_label_text (self , x , y , rotation ):
460
- dx , dy = self .ax .transData .inverted ().transform_point ((x , y ))
460
+ dx , dy = self .axes .transData .inverted ().transform_point ((x , y ))
461
461
t = text .Text (dx , dy , rotation = rotation ,
462
462
horizontalalignment = 'center' ,
463
463
verticalalignment = 'center' )
@@ -468,7 +468,7 @@ def _get_label_clabeltext(self, x, y, rotation):
468
468
# the data coordinate and create a label using ClabelText
469
469
# class. This way, the rotation of the clabel is along the
470
470
# contour line always.
471
- transDataInv = self .ax .transData .inverted ()
471
+ transDataInv = self .axes .transData .inverted ()
472
472
dx , dy = transDataInv .transform_point ((x , y ))
473
473
drotation = transDataInv .transform_angles (np .array ([rotation ]),
474
474
np .array ([[x , y ]]))
@@ -488,7 +488,7 @@ def _add_label(self, t, x, y, lev, cvalue):
488
488
self .labelXYs .append ((x , y ))
489
489
490
490
# Add label to plot here - useful for manual mode label selection
491
- self .ax .add_artist (t )
491
+ self .axes .add_artist (t )
492
492
493
493
def add_label (self , x , y , rotation , lev , cvalue ):
494
494
"""
@@ -534,7 +534,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
534
534
"""
535
535
536
536
if transform is None :
537
- transform = self .ax .transData
537
+ transform = self .axes .transData
538
538
539
539
if transform :
540
540
x , y = transform .transform_point ((x , y ))
@@ -553,7 +553,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
553
553
# grab its vertices
554
554
lc = active_path .vertices
555
555
# sort out where the new vertex should be added data-units
556
- xcmin = self .ax .transData .inverted ().transform_point ([xmin , ymin ])
556
+ xcmin = self .axes .transData .inverted ().transform_point ([xmin , ymin ])
557
557
# if there isn't a vertex close enough
558
558
if not np .allclose (xcmin , lc [imin ]):
559
559
# insert new data into the vertex list
@@ -569,13 +569,13 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
569
569
lc = paths [segmin ].vertices
570
570
571
571
# In pixel/screen space
572
- slc = self .ax .transData .transform (lc )
572
+ slc = self .axes .transData .transform (lc )
573
573
574
574
# Get label width for rotating labels and breaking contours
575
575
lw = self .get_label_width (self .labelLevelList [lmin ],
576
576
self .labelFmt , self .labelFontSizeList [lmin ])
577
577
# lw is in points.
578
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
578
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
579
579
# now lw in pixels
580
580
581
581
# Figure out label rotation.
@@ -619,7 +619,7 @@ def labels(self, inline, inline_spacing):
619
619
con = self .collections [icon ]
620
620
trans = con .get_transform ()
621
621
lw = self .get_label_width (lev , self .labelFmt , fsize )
622
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
622
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
623
623
additions = []
624
624
paths = con .get_paths ()
625
625
for segNum , linepath in enumerate (paths ):
@@ -840,7 +840,7 @@ def __init__(self, ax, *args,
840
840
Keyword arguments are as described in the docstring of
841
841
`~axes.Axes.contour`.
842
842
"""
843
- self .ax = ax
843
+ self .axes = ax
844
844
self .levels = levels
845
845
self .filled = filled
846
846
self .linewidths = linewidths
@@ -959,7 +959,7 @@ def __init__(self, ax, *args,
959
959
alpha = self .alpha ,
960
960
transform = self .get_transform (),
961
961
zorder = zorder )
962
- self .ax .add_collection (col , autolim = False )
962
+ self .axes .add_collection (col , autolim = False )
963
963
self .collections .append (col )
964
964
else :
965
965
tlinewidths = self ._process_linewidths ()
@@ -981,14 +981,14 @@ def __init__(self, ax, *args,
981
981
transform = self .get_transform (),
982
982
zorder = zorder )
983
983
col .set_label ('_nolegend_' )
984
- self .ax .add_collection (col , autolim = False )
984
+ self .axes .add_collection (col , autolim = False )
985
985
self .collections .append (col )
986
986
987
987
for col in self .collections :
988
988
col .sticky_edges .x [:] = [self ._mins [0 ], self ._maxs [0 ]]
989
989
col .sticky_edges .y [:] = [self ._mins [1 ], self ._maxs [1 ]]
990
- self .ax .update_datalim ([self ._mins , self ._maxs ])
991
- self .ax .autoscale_view (tight = True )
990
+ self .axes .update_datalim ([self ._mins , self ._maxs ])
991
+ self .axes .autoscale_view (tight = True )
992
992
993
993
self .changed () # set the colors
994
994
@@ -997,16 +997,21 @@ def __init__(self, ax, *args,
997
997
warnings .warn ('The following kwargs were not used by contour: ' +
998
998
s )
999
999
1000
+ @cbook .deprecated ("3.1" )
1001
+ @property
1002
+ def ax (self ):
1003
+ return self .axes
1004
+
1000
1005
def get_transform (self ):
1001
1006
"""
1002
1007
Return the :class:`~matplotlib.transforms.Transform`
1003
1008
instance used by this ContourSet.
1004
1009
"""
1005
1010
if self ._transform is None :
1006
- self ._transform = self .ax .transData
1011
+ self ._transform = self .axes .transData
1007
1012
elif (not isinstance (self ._transform , mtransforms .Transform )
1008
1013
and hasattr (self ._transform , '_as_mpl_transform' )):
1009
- self ._transform = self ._transform ._as_mpl_transform (self .ax )
1014
+ self ._transform = self ._transform ._as_mpl_transform (self .axes )
1010
1015
return self ._transform
1011
1016
1012
1017
def __getstate__ (self ):
@@ -1497,9 +1502,9 @@ def _process_args(self, *args, **kwargs):
1497
1502
1498
1503
# if the transform is not trans data, and some part of it
1499
1504
# contains transData, transform the xs and ys to data coordinates
1500
- if (t != self .ax .transData and
1501
- any (t .contains_branch_seperately (self .ax .transData ))):
1502
- trans_to_data = t - self .ax .transData
1505
+ if (t != self .axes .transData and
1506
+ any (t .contains_branch_seperately (self .axes .transData ))):
1507
+ trans_to_data = t - self .axes .transData
1503
1508
pts = (np .vstack ([x .flat , y .flat ]).T )
1504
1509
transformed_pts = trans_to_data .transform (pts )
1505
1510
x = transformed_pts [..., 0 ]
@@ -1567,9 +1572,9 @@ def _check_xyz(self, args, kwargs):
1567
1572
Exception class (here and elsewhere).
1568
1573
"""
1569
1574
x , y = args [:2 ]
1570
- kwargs = self .ax ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1571
- x = self .ax .convert_xunits (x )
1572
- y = self .ax .convert_yunits (y )
1575
+ kwargs = self .axes ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1576
+ x = self .axes .convert_xunits (x )
1577
+ y = self .axes .convert_yunits (y )
1573
1578
1574
1579
x = np .asarray (x , dtype = np .float64 )
1575
1580
y = np .asarray (y , dtype = np .float64 )
0 commit comments