diff --git a/examples/pylab_examples/polar_legend.py b/examples/pylab_examples/polar_legend.py index 8bd86f0e5d12..632f2e8bde0f 100755 --- a/examples/pylab_examples/polar_legend.py +++ b/examples/pylab_examples/polar_legend.py @@ -10,7 +10,8 @@ # force square figure and square axes looks better for polar, IMO fig = figure(figsize=(8, 8)) -ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], projection='polar', facecolor='#d5de9c') +ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], + projection='polar', facecolor='#d5de9c') r = np.arange(0, 3.0, 0.01) theta = 2*np.pi*r diff --git a/examples/widgets/radio_buttons.py b/examples/widgets/radio_buttons.py index b3df1454c48a..f993db59bf72 100644 --- a/examples/widgets/radio_buttons.py +++ b/examples/widgets/radio_buttons.py @@ -12,7 +12,7 @@ plt.subplots_adjust(left=0.3) axcolor = 'lightgoldenrodyellow' -rax = plt.axes([0.05, 0.7, 0.15, 0.15], axisbg=axcolor) +rax = plt.axes([0.05, 0.7, 0.15, 0.15], facecolor=axcolor) radio = RadioButtons(rax, ('2 Hz', '4 Hz', '8 Hz')) @@ -23,7 +23,7 @@ def hzfunc(label): plt.draw() radio.on_clicked(hzfunc) -rax = plt.axes([0.05, 0.4, 0.15, 0.15], axisbg=axcolor) +rax = plt.axes([0.05, 0.4, 0.15, 0.15], facecolor=axcolor) radio2 = RadioButtons(rax, ('red', 'blue', 'green')) @@ -32,7 +32,7 @@ def colorfunc(label): plt.draw() radio2.on_clicked(colorfunc) -rax = plt.axes([0.05, 0.1, 0.15, 0.15], axisbg=axcolor) +rax = plt.axes([0.05, 0.1, 0.15, 0.15], facecolor=axcolor) radio3 = RadioButtons(rax, ('-', '--', '-.', 'steps', ':')) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 050aa3c3408f..73075f5bbbd3 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -413,13 +413,14 @@ def __str__(self): return "Axes(%g,%g;%gx%g)" % tuple(self._position.bounds) def __init__(self, fig, rect, - axisbg=None, # defaults to rc axes.facecolor + facecolor=None, # defaults to rc axes.facecolor frameon=True, sharex=None, # use Axes instance's xaxis info sharey=None, # use Axes instance's yaxis info label='', xscale=None, yscale=None, + axisbg=None, # This will be removed eventually **kwargs ): """ @@ -508,13 +509,17 @@ def __init__(self, fig, rect, # this call may differ for non-sep axes, e.g., polar self._init_axis() - - if axisbg is None: - axisbg = rcParams['axes.facecolor'] - else: + if axisbg is not None and facecolor is not None: + raise TypeError('Both axisbg and facecolor are not None. ' + 'These keywords are aliases, only one may be ' + 'provided.') + if axisbg is not None: cbook.warn_deprecated( '2.0', name='axisbg', alternative='facecolor') - self._axisbg = axisbg + facecolor = axisbg + if facecolor is None: + facecolor = rcParams['axes.facecolor'] + self._facecolor = facecolor self._frameon = frameon self._axisbelow = rcParams['axes.axisbelow'] @@ -1053,7 +1058,7 @@ def cla(self): # setting the edgecolor to None self.patch = self.axesPatch = self._gen_axes_patch() self.patch.set_figure(self.figure) - self.patch.set_facecolor(self._axisbg) + self.patch.set_facecolor(self._facecolor) self.patch.set_edgecolor('None') self.patch.set_linewidth(0) self.patch.set_transform(self.transAxes) @@ -1083,6 +1088,7 @@ def get_facecolor(self): get_fc = get_facecolor def set_facecolor(self, color): + self._facecolor = color return self.patch.set_facecolor(color) set_fc = set_facecolor @@ -2709,7 +2715,7 @@ def set_axis_on(self): @cbook.deprecated('2.0', alternative='get_facecolor') def get_axis_bgcolor(self): """Return the axis background color""" - return self._axisbg + return self.get_facecolor() @cbook.deprecated('2.0', alternative='set_facecolor') def set_axis_bgcolor(self, color): @@ -2719,12 +2725,7 @@ def set_axis_bgcolor(self, color): ACCEPTS: any matplotlib color - see :func:`~matplotlib.pyplot.colors` """ - warnings.warn( - "set_axis_bgcolor is deprecated. Use set_facecolor instead.", - cbook.mplDeprecation) - self._axisbg = color - self.patch.set_facecolor(color) - self.stale = True + return self.set_facecolor(color) # data limits, ticks, tick labels, and formatting def invert_xaxis(self):