Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
API: finish changing axisbg -> facecolor
 - change name of first kwarg (third arg) of `_AxesBase.__init__`
   from 'axisbg' -> 'facecolor'.
 - added 'axisbg' back at the end of the listed kwargs
 - add handling from axisbg / facecolor conflicts

This adds a minor, but nasty, API wart in that there are now two
positional arguements to set the background color of the axes and API
wise we are locked into one positional arg.  However, if any non-None
value is passed for `axisbg` a warning will be raised and this is the
`__init__` on a private base class so should have reatively little
user exposure.
  • Loading branch information
tacaswell committed Feb 14, 2016
commit 0fe598c3a2572a31199003b673585ad1be1b1af4
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
17 changes: 11 additions & 6 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 maybe '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe -> 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._axisbg = facecolor
self._frameon = frameon
self._axisbelow = rcParams['axes.axisbelow']

Expand Down