Skip to content

Fix polar facecolor #6001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/pylab_examples/polar_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/widgets/radio_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))


Expand All @@ -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'))


Expand All @@ -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', ':'))


Expand Down
29 changes: 15 additions & 14 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
"""
Expand Down Expand Up @@ -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']

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down