@@ -413,13 +413,14 @@ def __str__(self):
413
413
return "Axes(%g,%g;%gx%g)" % tuple (self ._position .bounds )
414
414
415
415
def __init__ (self , fig , rect ,
416
- axisbg = None , # defaults to rc axes.facecolor
416
+ facecolor = None , # defaults to rc axes.facecolor
417
417
frameon = True ,
418
418
sharex = None , # use Axes instance's xaxis info
419
419
sharey = None , # use Axes instance's yaxis info
420
420
label = '' ,
421
421
xscale = None ,
422
422
yscale = None ,
423
+ axisbg = None , # This will be removed eventually
423
424
** kwargs
424
425
):
425
426
"""
@@ -508,13 +509,17 @@ def __init__(self, fig, rect,
508
509
509
510
# this call may differ for non-sep axes, e.g., polar
510
511
self ._init_axis ()
511
-
512
- if axisbg is None :
513
- axisbg = rcParams ['axes.facecolor' ]
514
- else :
512
+ if axisbg is not None and facecolor is not None :
513
+ raise TypeError ('Both axisbg and facecolor are not None. '
514
+ 'These keywords are aliases, only one may be '
515
+ 'provided.' )
516
+ if axisbg is not None :
515
517
cbook .warn_deprecated (
516
518
'2.0' , name = 'axisbg' , alternative = 'facecolor' )
517
- self ._axisbg = axisbg
519
+ facecolor = axisbg
520
+ if facecolor is None :
521
+ facecolor = rcParams ['axes.facecolor' ]
522
+ self ._facecolor = facecolor
518
523
self ._frameon = frameon
519
524
self ._axisbelow = rcParams ['axes.axisbelow' ]
520
525
@@ -1053,7 +1058,7 @@ def cla(self):
1053
1058
# setting the edgecolor to None
1054
1059
self .patch = self .axesPatch = self ._gen_axes_patch ()
1055
1060
self .patch .set_figure (self .figure )
1056
- self .patch .set_facecolor (self ._axisbg )
1061
+ self .patch .set_facecolor (self ._facecolor )
1057
1062
self .patch .set_edgecolor ('None' )
1058
1063
self .patch .set_linewidth (0 )
1059
1064
self .patch .set_transform (self .transAxes )
@@ -1083,6 +1088,7 @@ def get_facecolor(self):
1083
1088
get_fc = get_facecolor
1084
1089
1085
1090
def set_facecolor (self , color ):
1091
+ self ._facecolor = color
1086
1092
return self .patch .set_facecolor (color )
1087
1093
set_fc = set_facecolor
1088
1094
@@ -2709,7 +2715,7 @@ def set_axis_on(self):
2709
2715
@cbook .deprecated ('2.0' , alternative = 'get_facecolor' )
2710
2716
def get_axis_bgcolor (self ):
2711
2717
"""Return the axis background color"""
2712
- return self ._axisbg
2718
+ return self .get_facecolor ()
2713
2719
2714
2720
@cbook .deprecated ('2.0' , alternative = 'set_facecolor' )
2715
2721
def set_axis_bgcolor (self , color ):
@@ -2719,12 +2725,7 @@ def set_axis_bgcolor(self, color):
2719
2725
ACCEPTS: any matplotlib color - see
2720
2726
:func:`~matplotlib.pyplot.colors`
2721
2727
"""
2722
- warnings .warn (
2723
- "set_axis_bgcolor is deprecated. Use set_facecolor instead." ,
2724
- cbook .mplDeprecation )
2725
- self ._axisbg = color
2726
- self .patch .set_facecolor (color )
2727
- self .stale = True
2728
+ return self .set_facecolor (color )
2728
2729
# data limits, ticks, tick labels, and formatting
2729
2730
2730
2731
def invert_xaxis (self ):
0 commit comments