@@ -254,7 +254,7 @@ def set_label_props(self, label, text, color):
254
254
label .set_text (text )
255
255
label .set_color (color )
256
256
label .set_fontproperties (self .labelFontProps )
257
- label .set_clip_box (self .ax .bbox )
257
+ label .set_clip_box (self .axes .bbox )
258
258
259
259
def get_text (self , lev , fmt ):
260
260
"""Get the text of the label."""
@@ -396,7 +396,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
396
396
return rotation , nlc
397
397
398
398
def _get_label_text (self , x , y , rotation ):
399
- dx , dy = self .ax .transData .inverted ().transform ((x , y ))
399
+ dx , dy = self .axes .transData .inverted ().transform ((x , y ))
400
400
t = text .Text (dx , dy , rotation = rotation ,
401
401
horizontalalignment = 'center' ,
402
402
verticalalignment = 'center' )
@@ -407,7 +407,7 @@ def _get_label_clabeltext(self, x, y, rotation):
407
407
# the data coordinate and create a label using ClabelText
408
408
# class. This way, the rotation of the clabel is along the
409
409
# contour line always.
410
- transDataInv = self .ax .transData .inverted ()
410
+ transDataInv = self .axes .transData .inverted ()
411
411
dx , dy = transDataInv .transform ((x , y ))
412
412
drotation = transDataInv .transform_angles (np .array ([rotation ]),
413
413
np .array ([[x , y ]]))
@@ -427,7 +427,7 @@ def _add_label(self, t, x, y, lev, cvalue):
427
427
self .labelXYs .append ((x , y ))
428
428
429
429
# Add label to plot here - useful for manual mode label selection
430
- self .ax .add_artist (t )
430
+ self .axes .add_artist (t )
431
431
432
432
def add_label (self , x , y , rotation , lev , cvalue ):
433
433
"""
@@ -471,7 +471,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
471
471
"""
472
472
473
473
if transform is None :
474
- transform = self .ax .transData
474
+ transform = self .axes .transData
475
475
476
476
if transform :
477
477
x , y = transform .transform ((x , y ))
@@ -490,7 +490,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
490
490
# grab its vertices
491
491
lc = active_path .vertices
492
492
# sort out where the new vertex should be added data-units
493
- xcmin = self .ax .transData .inverted ().transform ([xmin , ymin ])
493
+ xcmin = self .axes .transData .inverted ().transform ([xmin , ymin ])
494
494
# if there isn't a vertex close enough
495
495
if not np .allclose (xcmin , lc [imin ]):
496
496
# insert new data into the vertex list
@@ -506,13 +506,13 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
506
506
lc = paths [segmin ].vertices
507
507
508
508
# In pixel/screen space
509
- slc = self .ax .transData .transform (lc )
509
+ slc = self .axes .transData .transform (lc )
510
510
511
511
# Get label width for rotating labels and breaking contours
512
512
lw = self .get_label_width (self .labelLevelList [lmin ],
513
513
self .labelFmt , self .labelFontSizeList [lmin ])
514
514
# lw is in points.
515
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
515
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
516
516
# now lw in pixels
517
517
518
518
# 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 ):
@@ -777,7 +777,7 @@ def __init__(self, ax, *args,
777
777
Keyword arguments are as described in the docstring of
778
778
`~axes.Axes.contour`.
779
779
"""
780
- self .ax = ax
780
+ self .axes = ax
781
781
self .levels = levels
782
782
self .filled = filled
783
783
self .linewidths = linewidths
@@ -893,7 +893,7 @@ def __init__(self, ax, *args,
893
893
alpha = self .alpha ,
894
894
transform = self .get_transform (),
895
895
zorder = zorder )
896
- self .ax .add_collection (col , autolim = False )
896
+ self .axes .add_collection (col , autolim = False )
897
897
self .collections .append (col )
898
898
else :
899
899
tlinewidths = self ._process_linewidths ()
@@ -915,14 +915,14 @@ def __init__(self, ax, *args,
915
915
transform = self .get_transform (),
916
916
zorder = zorder )
917
917
col .set_label ('_nolegend_' )
918
- self .ax .add_collection (col , autolim = False )
918
+ self .axes .add_collection (col , autolim = False )
919
919
self .collections .append (col )
920
920
921
921
for col in self .collections :
922
922
col .sticky_edges .x [:] = [self ._mins [0 ], self ._maxs [0 ]]
923
923
col .sticky_edges .y [:] = [self ._mins [1 ], self ._maxs [1 ]]
924
- self .ax .update_datalim ([self ._mins , self ._maxs ])
925
- self .ax .autoscale_view (tight = True )
924
+ self .axes .update_datalim ([self ._mins , self ._maxs ])
925
+ self .axes .autoscale_view (tight = True )
926
926
927
927
self .changed () # set the colors
928
928
@@ -931,16 +931,21 @@ def __init__(self, ax, *args,
931
931
cbook ._warn_external ('The following kwargs were not used by '
932
932
'contour: ' + s )
933
933
934
+ @cbook .deprecated ("3.3" )
935
+ @property
936
+ def ax (self ):
937
+ return self .axes
938
+
934
939
def get_transform (self ):
935
940
"""
936
941
Return the :class:`~matplotlib.transforms.Transform`
937
942
instance used by this ContourSet.
938
943
"""
939
944
if self ._transform is None :
940
- self ._transform = self .ax .transData
945
+ self ._transform = self .axes .transData
941
946
elif (not isinstance (self ._transform , mtransforms .Transform )
942
947
and hasattr (self ._transform , '_as_mpl_transform' )):
943
- self ._transform = self ._transform ._as_mpl_transform (self .ax )
948
+ self ._transform = self ._transform ._as_mpl_transform (self .axes )
944
949
return self ._transform
945
950
946
951
def __getstate__ (self ):
@@ -1426,9 +1431,9 @@ def _process_args(self, *args, **kwargs):
1426
1431
1427
1432
# if the transform is not trans data, and some part of it
1428
1433
# contains transData, transform the xs and ys to data coordinates
1429
- if (t != self .ax .transData and
1430
- any (t .contains_branch_seperately (self .ax .transData ))):
1431
- trans_to_data = t - self .ax .transData
1434
+ if (t != self .axes .transData and
1435
+ any (t .contains_branch_seperately (self .axes .transData ))):
1436
+ trans_to_data = t - self .axes .transData
1432
1437
pts = (np .vstack ([x .flat , y .flat ]).T )
1433
1438
transformed_pts = trans_to_data .transform (pts )
1434
1439
x = transformed_pts [..., 0 ]
@@ -1493,9 +1498,9 @@ def _check_xyz(self, args, kwargs):
1493
1498
convert them to 2D using meshgrid.
1494
1499
"""
1495
1500
x , y = args [:2 ]
1496
- kwargs = self .ax ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1497
- x = self .ax .convert_xunits (x )
1498
- y = self .ax .convert_yunits (y )
1501
+ kwargs = self .axes ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1502
+ x = self .axes .convert_xunits (x )
1503
+ y = self .axes .convert_yunits (y )
1499
1504
1500
1505
x = np .asarray (x , dtype = np .float64 )
1501
1506
y = np .asarray (y , dtype = np .float64 )
0 commit comments