Skip to content

Commit 47b70ea

Browse files
committed
Merge pull request #6001 from tacaswell/fix_polar_facecolor
Fix polar facecolor
2 parents 756102c + df3e4bc commit 47b70ea

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

examples/pylab_examples/polar_legend.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
# force square figure and square axes looks better for polar, IMO
1212
fig = figure(figsize=(8, 8))
13-
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], projection='polar', facecolor='#d5de9c')
13+
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8],
14+
projection='polar', facecolor='#d5de9c')
1415

1516
r = np.arange(0, 3.0, 0.01)
1617
theta = 2*np.pi*r

examples/widgets/radio_buttons.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
plt.subplots_adjust(left=0.3)
1313

1414
axcolor = 'lightgoldenrodyellow'
15-
rax = plt.axes([0.05, 0.7, 0.15, 0.15], axisbg=axcolor)
15+
rax = plt.axes([0.05, 0.7, 0.15, 0.15], facecolor=axcolor)
1616
radio = RadioButtons(rax, ('2 Hz', '4 Hz', '8 Hz'))
1717

1818

@@ -23,7 +23,7 @@ def hzfunc(label):
2323
plt.draw()
2424
radio.on_clicked(hzfunc)
2525

26-
rax = plt.axes([0.05, 0.4, 0.15, 0.15], axisbg=axcolor)
26+
rax = plt.axes([0.05, 0.4, 0.15, 0.15], facecolor=axcolor)
2727
radio2 = RadioButtons(rax, ('red', 'blue', 'green'))
2828

2929

@@ -32,7 +32,7 @@ def colorfunc(label):
3232
plt.draw()
3333
radio2.on_clicked(colorfunc)
3434

35-
rax = plt.axes([0.05, 0.1, 0.15, 0.15], axisbg=axcolor)
35+
rax = plt.axes([0.05, 0.1, 0.15, 0.15], facecolor=axcolor)
3636
radio3 = RadioButtons(rax, ('-', '--', '-.', 'steps', ':'))
3737

3838

lib/matplotlib/axes/_base.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)