@@ -261,7 +261,7 @@ def set_label_props(self, label, text, color):
261
261
label .set_text (text )
262
262
label .set_color (color )
263
263
label .set_fontproperties (self .labelFontProps )
264
- label .set_clip_box (self .ax .bbox )
264
+ label .set_clip_box (self .axes .bbox )
265
265
266
266
def get_text (self , lev , fmt ):
267
267
"""Get the text of the label."""
@@ -401,7 +401,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
401
401
return rotation , nlc
402
402
403
403
def _get_label_text (self , x , y , rotation ):
404
- dx , dy = self .ax .transData .inverted ().transform ((x , y ))
404
+ dx , dy = self .axes .transData .inverted ().transform ((x , y ))
405
405
t = text .Text (dx , dy , rotation = rotation ,
406
406
horizontalalignment = 'center' ,
407
407
verticalalignment = 'center' , zorder = self ._clabel_zorder )
@@ -412,7 +412,7 @@ def _get_label_clabeltext(self, x, y, rotation):
412
412
# the data coordinate and create a label using ClabelText
413
413
# class. This way, the rotation of the clabel is along the
414
414
# contour line always.
415
- transDataInv = self .ax .transData .inverted ()
415
+ transDataInv = self .axes .transData .inverted ()
416
416
dx , dy = transDataInv .transform ((x , y ))
417
417
drotation = transDataInv .transform_angles (np .array ([rotation ]),
418
418
np .array ([[x , y ]]))
@@ -432,7 +432,7 @@ def _add_label(self, t, x, y, lev, cvalue):
432
432
self .labelXYs .append ((x , y ))
433
433
434
434
# Add label to plot here - useful for manual mode label selection
435
- self .ax .add_artist (t )
435
+ self .axes .add_artist (t )
436
436
437
437
def add_label (self , x , y , rotation , lev , cvalue ):
438
438
"""
@@ -476,7 +476,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
476
476
"""
477
477
478
478
if transform is None :
479
- transform = self .ax .transData
479
+ transform = self .axes .transData
480
480
481
481
if transform :
482
482
x , y = transform .transform ((x , y ))
@@ -495,7 +495,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
495
495
# grab its vertices
496
496
lc = active_path .vertices
497
497
# sort out where the new vertex should be added data-units
498
- xcmin = self .ax .transData .inverted ().transform ([xmin , ymin ])
498
+ xcmin = self .axes .transData .inverted ().transform ([xmin , ymin ])
499
499
# if there isn't a vertex close enough
500
500
if not np .allclose (xcmin , lc [imin ]):
501
501
# insert new data into the vertex list
@@ -511,13 +511,13 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
511
511
lc = paths [segmin ].vertices
512
512
513
513
# In pixel/screen space
514
- slc = self .ax .transData .transform (lc )
514
+ slc = self .axes .transData .transform (lc )
515
515
516
516
# Get label width for rotating labels and breaking contours
517
517
lw = self .get_label_width (self .labelLevelList [lmin ],
518
518
self .labelFmt , self .labelFontSizeList [lmin ])
519
519
# lw is in points.
520
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
520
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
521
521
# now lw in pixels
522
522
523
523
# Figure out label rotation.
@@ -556,7 +556,7 @@ def labels(self, inline, inline_spacing):
556
556
con = self .collections [icon ]
557
557
trans = con .get_transform ()
558
558
lw = self .get_label_width (lev , self .labelFmt , fsize )
559
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
559
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
560
560
additions = []
561
561
paths = con .get_paths ()
562
562
for segNum , linepath in enumerate (paths ):
@@ -773,7 +773,7 @@ def __init__(self, ax, *args,
773
773
Keyword arguments are as described in the docstring of
774
774
`~.Axes.contour`.
775
775
"""
776
- self .ax = ax
776
+ self .axes = ax
777
777
self .levels = levels
778
778
self .filled = filled
779
779
self .linewidths = linewidths
@@ -889,7 +889,7 @@ def __init__(self, ax, *args,
889
889
alpha = self .alpha ,
890
890
transform = self .get_transform (),
891
891
zorder = self ._contour_zorder )
892
- self .ax .add_collection (col , autolim = False )
892
+ self .axes .add_collection (col , autolim = False )
893
893
self .collections .append (col )
894
894
else :
895
895
tlinewidths = self ._process_linewidths ()
@@ -911,14 +911,14 @@ def __init__(self, ax, *args,
911
911
transform = self .get_transform (),
912
912
zorder = self ._contour_zorder )
913
913
col .set_label ('_nolegend_' )
914
- self .ax .add_collection (col , autolim = False )
914
+ self .axes .add_collection (col , autolim = False )
915
915
self .collections .append (col )
916
916
917
917
for col in self .collections :
918
918
col .sticky_edges .x [:] = [self ._mins [0 ], self ._maxs [0 ]]
919
919
col .sticky_edges .y [:] = [self ._mins [1 ], self ._maxs [1 ]]
920
- self .ax .update_datalim ([self ._mins , self ._maxs ])
921
- self .ax .autoscale_view (tight = True )
920
+ self .axes .update_datalim ([self ._mins , self ._maxs ])
921
+ self .axes .autoscale_view (tight = True )
922
922
923
923
self .changed () # set the colors
924
924
@@ -927,16 +927,21 @@ def __init__(self, ax, *args,
927
927
cbook ._warn_external ('The following kwargs were not used by '
928
928
'contour: ' + s )
929
929
930
+ @cbook .deprecated ("3.3" )
931
+ @property
932
+ def ax (self ):
933
+ return self .axes
934
+
930
935
def get_transform (self ):
931
936
"""
932
937
Return the :class:`~matplotlib.transforms.Transform`
933
938
instance used by this ContourSet.
934
939
"""
935
940
if self ._transform is None :
936
- self ._transform = self .ax .transData
941
+ self ._transform = self .axes .transData
937
942
elif (not isinstance (self ._transform , mtransforms .Transform )
938
943
and hasattr (self ._transform , '_as_mpl_transform' )):
939
- self ._transform = self ._transform ._as_mpl_transform (self .ax )
944
+ self ._transform = self ._transform ._as_mpl_transform (self .axes )
940
945
return self ._transform
941
946
942
947
def __getstate__ (self ):
@@ -1431,9 +1436,9 @@ def _process_args(self, *args, corner_mask=None, **kwargs):
1431
1436
1432
1437
# if the transform is not trans data, and some part of it
1433
1438
# contains transData, transform the xs and ys to data coordinates
1434
- if (t != self .ax .transData and
1435
- any (t .contains_branch_seperately (self .ax .transData ))):
1436
- trans_to_data = t - self .ax .transData
1439
+ if (t != self .axes .transData and
1440
+ any (t .contains_branch_seperately (self .axes .transData ))):
1441
+ trans_to_data = t - self .axes .transData
1437
1442
pts = np .vstack ([x .flat , y .flat ]).T
1438
1443
transformed_pts = trans_to_data .transform (pts )
1439
1444
x = transformed_pts [..., 0 ]
@@ -1498,9 +1503,9 @@ def _check_xyz(self, args, kwargs):
1498
1503
convert them to 2D using meshgrid.
1499
1504
"""
1500
1505
x , y = args [:2 ]
1501
- kwargs = self .ax ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1502
- x = self .ax .convert_xunits (x )
1503
- y = self .ax .convert_yunits (y )
1506
+ kwargs = self .axes ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1507
+ x = self .axes .convert_xunits (x )
1508
+ y = self .axes .convert_yunits (y )
1504
1509
1505
1510
x = np .asarray (x , dtype = np .float64 )
1506
1511
y = np .asarray (y , dtype = np .float64 )
0 commit comments