@@ -413,13 +413,14 @@ def __str__(self):
413413 return "Axes(%g,%g;%gx%g)" % tuple (self ._position .bounds )
414414
415415 def __init__ (self , fig , rect ,
416- axisbg = None , # defaults to rc axes.facecolor
416+ facecolor = None , # defaults to rc axes.facecolor
417417 frameon = True ,
418418 sharex = None , # use Axes instance's xaxis info
419419 sharey = None , # use Axes instance's yaxis info
420420 label = '' ,
421421 xscale = None ,
422422 yscale = None ,
423+ axisbg = None , # This will be removed eventually
423424 ** kwargs
424425 ):
425426 """
@@ -508,13 +509,17 @@ def __init__(self, fig, rect,
508509
509510 # this call may differ for non-sep axes, e.g., polar
510511 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 :
515517 cbook .warn_deprecated (
516518 '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
518523 self ._frameon = frameon
519524 self ._axisbelow = rcParams ['axes.axisbelow' ]
520525
@@ -1053,7 +1058,7 @@ def cla(self):
10531058 # setting the edgecolor to None
10541059 self .patch = self .axesPatch = self ._gen_axes_patch ()
10551060 self .patch .set_figure (self .figure )
1056- self .patch .set_facecolor (self ._axisbg )
1061+ self .patch .set_facecolor (self ._facecolor )
10571062 self .patch .set_edgecolor ('None' )
10581063 self .patch .set_linewidth (0 )
10591064 self .patch .set_transform (self .transAxes )
@@ -1083,6 +1088,7 @@ def get_facecolor(self):
10831088 get_fc = get_facecolor
10841089
10851090 def set_facecolor (self , color ):
1091+ self ._facecolor = color
10861092 return self .patch .set_facecolor (color )
10871093 set_fc = set_facecolor
10881094
@@ -2709,7 +2715,7 @@ def set_axis_on(self):
27092715 @cbook .deprecated ('2.0' , alternative = 'get_facecolor' )
27102716 def get_axis_bgcolor (self ):
27112717 """Return the axis background color"""
2712- return self ._axisbg
2718+ return self .get_facecolor ()
27132719
27142720 @cbook .deprecated ('2.0' , alternative = 'set_facecolor' )
27152721 def set_axis_bgcolor (self , color ):
@@ -2719,12 +2725,7 @@ def set_axis_bgcolor(self, color):
27192725 ACCEPTS: any matplotlib color - see
27202726 :func:`~matplotlib.pyplot.colors`
27212727 """
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 )
27282729 # data limits, ticks, tick labels, and formatting
27292730
27302731 def invert_xaxis (self ):
0 commit comments