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