@@ -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."""
@@ -394,7 +394,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
394
394
return rotation , nlc
395
395
396
396
def _get_label_text (self , x , y , rotation ):
397
- dx , dy = self .ax .transData .inverted ().transform ((x , y ))
397
+ dx , dy = self .axes .transData .inverted ().transform ((x , y ))
398
398
t = text .Text (dx , dy , rotation = rotation ,
399
399
horizontalalignment = 'center' ,
400
400
verticalalignment = 'center' )
@@ -405,7 +405,7 @@ def _get_label_clabeltext(self, x, y, rotation):
405
405
# the data coordinate and create a label using ClabelText
406
406
# class. This way, the rotation of the clabel is along the
407
407
# contour line always.
408
- transDataInv = self .ax .transData .inverted ()
408
+ transDataInv = self .axes .transData .inverted ()
409
409
dx , dy = transDataInv .transform ((x , y ))
410
410
drotation = transDataInv .transform_angles (np .array ([rotation ]),
411
411
np .array ([[x , y ]]))
@@ -425,7 +425,7 @@ def _add_label(self, t, x, y, lev, cvalue):
425
425
self .labelXYs .append ((x , y ))
426
426
427
427
# Add label to plot here - useful for manual mode label selection
428
- self .ax .add_artist (t )
428
+ self .axes .add_artist (t )
429
429
430
430
def add_label (self , x , y , rotation , lev , cvalue ):
431
431
"""
@@ -469,7 +469,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
469
469
"""
470
470
471
471
if transform is None :
472
- transform = self .ax .transData
472
+ transform = self .axes .transData
473
473
474
474
if transform :
475
475
x , y = transform .transform ((x , y ))
@@ -488,7 +488,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
488
488
# grab its vertices
489
489
lc = active_path .vertices
490
490
# sort out where the new vertex should be added data-units
491
- xcmin = self .ax .transData .inverted ().transform ([xmin , ymin ])
491
+ xcmin = self .axes .transData .inverted ().transform ([xmin , ymin ])
492
492
# if there isn't a vertex close enough
493
493
if not np .allclose (xcmin , lc [imin ]):
494
494
# insert new data into the vertex list
@@ -504,13 +504,13 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
504
504
lc = paths [segmin ].vertices
505
505
506
506
# In pixel/screen space
507
- slc = self .ax .transData .transform (lc )
507
+ slc = self .axes .transData .transform (lc )
508
508
509
509
# Get label width for rotating labels and breaking contours
510
510
lw = self .get_label_width (self .labelLevelList [lmin ],
511
511
self .labelFmt , self .labelFontSizeList [lmin ])
512
512
# lw is in points.
513
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
513
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
514
514
# now lw in pixels
515
515
516
516
# Figure out label rotation.
@@ -549,7 +549,7 @@ def labels(self, inline, inline_spacing):
549
549
con = self .collections [icon ]
550
550
trans = con .get_transform ()
551
551
lw = self .get_label_width (lev , self .labelFmt , fsize )
552
- lw *= self .ax .figure .dpi / 72.0 # scale to screen coordinates
552
+ lw *= self .axes .figure .dpi / 72 # scale to screen coordinates
553
553
additions = []
554
554
paths = con .get_paths ()
555
555
for segNum , linepath in enumerate (paths ):
@@ -765,7 +765,7 @@ def __init__(self, ax, *args,
765
765
Keyword arguments are as described in the docstring of
766
766
`~.Axes.contour`.
767
767
"""
768
- self .ax = ax
768
+ self .axes = ax
769
769
self .levels = levels
770
770
self .filled = filled
771
771
self .linewidths = linewidths
@@ -881,7 +881,7 @@ def __init__(self, ax, *args,
881
881
alpha = self .alpha ,
882
882
transform = self .get_transform (),
883
883
zorder = zorder )
884
- self .ax .add_collection (col , autolim = False )
884
+ self .axes .add_collection (col , autolim = False )
885
885
self .collections .append (col )
886
886
else :
887
887
tlinewidths = self ._process_linewidths ()
@@ -903,14 +903,14 @@ def __init__(self, ax, *args,
903
903
transform = self .get_transform (),
904
904
zorder = zorder )
905
905
col .set_label ('_nolegend_' )
906
- self .ax .add_collection (col , autolim = False )
906
+ self .axes .add_collection (col , autolim = False )
907
907
self .collections .append (col )
908
908
909
909
for col in self .collections :
910
910
col .sticky_edges .x [:] = [self ._mins [0 ], self ._maxs [0 ]]
911
911
col .sticky_edges .y [:] = [self ._mins [1 ], self ._maxs [1 ]]
912
- self .ax .update_datalim ([self ._mins , self ._maxs ])
913
- self .ax .autoscale_view (tight = True )
912
+ self .axes .update_datalim ([self ._mins , self ._maxs ])
913
+ self .axes .autoscale_view (tight = True )
914
914
915
915
self .changed () # set the colors
916
916
@@ -919,16 +919,21 @@ def __init__(self, ax, *args,
919
919
cbook ._warn_external ('The following kwargs were not used by '
920
920
'contour: ' + s )
921
921
922
+ @cbook .deprecated ("3.3" )
923
+ @property
924
+ def ax (self ):
925
+ return self .axes
926
+
922
927
def get_transform (self ):
923
928
"""
924
929
Return the :class:`~matplotlib.transforms.Transform`
925
930
instance used by this ContourSet.
926
931
"""
927
932
if self ._transform is None :
928
- self ._transform = self .ax .transData
933
+ self ._transform = self .axes .transData
929
934
elif (not isinstance (self ._transform , mtransforms .Transform )
930
935
and hasattr (self ._transform , '_as_mpl_transform' )):
931
- self ._transform = self ._transform ._as_mpl_transform (self .ax )
936
+ self ._transform = self ._transform ._as_mpl_transform (self .axes )
932
937
return self ._transform
933
938
934
939
def __getstate__ (self ):
@@ -1414,9 +1419,9 @@ def _process_args(self, *args, **kwargs):
1414
1419
1415
1420
# if the transform is not trans data, and some part of it
1416
1421
# contains transData, transform the xs and ys to data coordinates
1417
- if (t != self .ax .transData and
1418
- any (t .contains_branch_seperately (self .ax .transData ))):
1419
- trans_to_data = t - self .ax .transData
1422
+ if (t != self .axes .transData and
1423
+ any (t .contains_branch_seperately (self .axes .transData ))):
1424
+ trans_to_data = t - self .axes .transData
1420
1425
pts = np .vstack ([x .flat , y .flat ]).T
1421
1426
transformed_pts = trans_to_data .transform (pts )
1422
1427
x = transformed_pts [..., 0 ]
@@ -1481,9 +1486,9 @@ def _check_xyz(self, args, kwargs):
1481
1486
convert them to 2D using meshgrid.
1482
1487
"""
1483
1488
x , y = args [:2 ]
1484
- kwargs = self .ax ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1485
- x = self .ax .convert_xunits (x )
1486
- y = self .ax .convert_yunits (y )
1489
+ kwargs = self .axes ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
1490
+ x = self .axes .convert_xunits (x )
1491
+ y = self .axes .convert_yunits (y )
1487
1492
1488
1493
x = np .asarray (x , dtype = np .float64 )
1489
1494
y = np .asarray (y , dtype = np .float64 )
0 commit comments