@@ -260,7 +260,7 @@ def set_label_props(self, label, text, color):
260
260
label .set_text (text )
261
261
label .set_color (color )
262
262
label .set_fontproperties (self .labelFontProps )
263
- label .set_clip_box (self .ax .bbox )
263
+ label .set_clip_box (self .axes .bbox )
264
264
265
265
def get_text (self , lev , fmt ):
266
266
"""Get the text of the label."""
@@ -402,7 +402,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
402
402
return rotation , nlc
403
403
404
404
def _get_label_text (self , x , y , rotation ):
405
- dx , dy = self .ax .transData .inverted ().transform ((x , y ))
405
+ dx , dy = self .axes .transData .inverted ().transform ((x , y ))
406
406
t = text .Text (dx , dy , rotation = rotation ,
407
407
horizontalalignment = 'center' ,
408
408
verticalalignment = 'center' )
@@ -413,7 +413,7 @@ def _get_label_clabeltext(self, x, y, rotation):
413
413
# the data coordinate and create a label using ClabelText
414
414
# class. This way, the rotation of the clabel is along the
415
415
# contour line always.
416
- transDataInv = self .ax .transData .inverted ()
416
+ transDataInv = self .axes .transData .inverted ()
417
417
dx , dy = transDataInv .transform ((x , y ))
418
418
drotation = transDataInv .transform_angles (np .array ([rotation ]),
419
419
np .array ([[x , y ]]))
@@ -433,7 +433,7 @@ def _add_label(self, t, x, y, lev, cvalue):
433
433
self .labelXYs .append ((x , y ))
434
434
435
435
# Add label to plot here - useful for manual mode label selection
436
- self .ax .add_artist (t )
436
+ self .axes .add_artist (t )
437
437
438
438
def add_label (self , x , y , rotation , lev , cvalue ):
439
439
"""
@@ -477,7 +477,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
477
477
"""
478
478
479
479
if transform is None :
480
- transform = self .ax .transData
480
+ transform = self .axes .transData
481
481
482
482
if transform :
483
483
x , y = transform .transform ((x , y ))
@@ -496,7 +496,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
496
496
# grab its vertices
497
497
lc = active_path .vertices
498
498
# sort out where the new vertex should be added data-units
499
- xcmin = self .ax .transData .inverted ().transform ([xmin , ymin ])
499
+ xcmin = self .axes .transData .inverted ().transform ([xmin , ymin ])
500
500
# if there isn't a vertex close enough
501
501
if not np .allclose (xcmin , lc [imin ]):
502
502
# insert new data into the vertex list
@@ -512,13 +512,13 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
512
512
lc = paths [segmin ].vertices
513
513
514
514
# In pixel/screen space
515
- slc = self .ax .transData .transform (lc )
515
+ slc = self .axes .transData .transform (lc )
516
516
517
517
# Get label width for rotating labels and breaking contours
518
518
lw = self .get_label_width (self .labelLevelList [lmin ],
519
519
self .labelFmt , self .labelFontSizeList [lmin ])
520
520
# lw is in points.
521
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
521
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
522
522
# now lw in pixels
523
523
524
524
# Figure out label rotation.
@@ -562,7 +562,7 @@ def labels(self, inline, inline_spacing):
562
562
con = self .collections [icon ]
563
563
trans = con .get_transform ()
564
564
lw = self .get_label_width (lev , self .labelFmt , fsize )
565
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
565
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
566
566
additions = []
567
567
paths = con .get_paths ()
568
568
for segNum , linepath in enumerate (paths ):
@@ -784,7 +784,7 @@ def __init__(self, ax, *args,
784
784
Keyword arguments are as described in the docstring of
785
785
`~axes.Axes.contour`.
786
786
"""
787
- self .ax = ax
787
+ self .axes = ax
788
788
self .levels = levels
789
789
self .filled = filled
790
790
self .linewidths = linewidths
@@ -900,7 +900,7 @@ def __init__(self, ax, *args,
900
900
alpha = self .alpha ,
901
901
transform = self .get_transform (),
902
902
zorder = zorder )
903
- self .ax .add_collection (col , autolim = False )
903
+ self .axes .add_collection (col , autolim = False )
904
904
self .collections .append (col )
905
905
else :
906
906
tlinewidths = self ._process_linewidths ()
@@ -922,14 +922,14 @@ def __init__(self, ax, *args,
922
922
transform = self .get_transform (),
923
923
zorder = zorder )
924
924
col .set_label ('_nolegend_' )
925
- self .ax .add_collection (col , autolim = False )
925
+ self .axes .add_collection (col , autolim = False )
926
926
self .collections .append (col )
927
927
928
928
for col in self .collections :
929
929
col .sticky_edges .x [:] = [self ._mins [0 ], self ._maxs [0 ]]
930
930
col .sticky_edges .y [:] = [self ._mins [1 ], self ._maxs [1 ]]
931
- self .ax .update_datalim ([self ._mins , self ._maxs ])
932
- self .ax .autoscale_view (tight = True )
931
+ self .axes .update_datalim ([self ._mins , self ._maxs ])
932
+ self .axes .autoscale_view (tight = True )
933
933
934
934
self .changed () # set the colors
935
935
@@ -938,16 +938,21 @@ def __init__(self, ax, *args,
938
938
cbook ._warn_external ('The following kwargs were not used by '
939
939
'contour: ' + s )
940
940
941
+ @cbook .deprecated ("3.1" )
942
+ @property
943
+ def ax (self ):
944
+ return self .axes
945
+
941
946
def get_transform (self ):
942
947
"""
943
948
Return the :class:`~matplotlib.transforms.Transform`
944
949
instance used by this ContourSet.
945
950
"""
946
951
if self ._transform is None :
947
- self ._transform = self .ax .transData
952
+ self ._transform = self .axes .transData
948
953
elif (not isinstance (self ._transform , mtransforms .Transform )
949
954
and hasattr (self ._transform , '_as_mpl_transform' )):
950
- self ._transform = self ._transform ._as_mpl_transform (self .ax )
955
+ self ._transform = self ._transform ._as_mpl_transform (self .axes )
951
956
return self ._transform
952
957
953
958
def __getstate__ (self ):
@@ -1433,9 +1438,9 @@ def _process_args(self, *args, **kwargs):
1433
1438
1434
1439
# if the transform is not trans data, and some part of it
1435
1440
# contains transData, transform the xs and ys to data coordinates
1436
- if (t != self .ax .transData and
1437
- any (t .contains_branch_seperately (self .ax .transData ))):
1438
- trans_to_data = t - self .ax .transData
1441
+ if (t != self .axes .transData and
1442
+ any (t .contains_branch_seperately (self .axes .transData ))):
1443
+ trans_to_data = t - self .axes .transData
1439
1444
pts = (np .vstack ([x .flat , y .flat ]).T )
1440
1445
transformed_pts = trans_to_data .transform (pts )
1441
1446
x = transformed_pts [..., 0 ]
@@ -1504,9 +1509,9 @@ def _check_xyz(self, args, kwargs):
1504
1509
Exception class (here and elsewhere).
1505
1510
"""
1506
1511
x , y = args [:2 ]
1507
- kwargs = self .ax ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1508
- x = self .ax .convert_xunits (x )
1509
- y = self .ax .convert_yunits (y )
1512
+ kwargs = self .axes ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1513
+ x = self .axes .convert_xunits (x )
1514
+ y = self .axes .convert_yunits (y )
1510
1515
1511
1516
x = np .asarray (x , dtype = np .float64 )
1512
1517
y = np .asarray (y , dtype = np .float64 )
0 commit comments