Skip to content

Commit be4cb3e

Browse files
author
Yaron de Leeuw
committed
remove some redunancy in _BaseAxes
While working on matplotlib#1460, I've found that the `__init__` of `_BaseAxes` takes some redundant arguments. Of the 7 arguments it takes, 3 (`xscale, yscale, label`) can be removed without harm, because they are automatically used in `update(kwargs)` (they have matching `set_` methods). Another two have different names as setters: `frameon` == `frame_on` and `axisbg` ~ `axis_bgcolor`. Note that the later are mispelled, as they refer to axes and not axis. The following call is actually legal: plt.subplot(111, axisbg='green', axis_bgcolor='red') I do not know what to do with the other two arguments. (`sharex` `sharey`) I've tried to remove this redunancy, keeping the old defaults intact, and without breaking the api. My opinion is that axisbg and frameon should be reomved, but api changes and deprectations are above my level. See also issue matplotlib#1460
1 parent 7a9f234 commit be4cb3e

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

‎lib/matplotlib/axes/_base.py‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@ def __init__(self, fig, rect,
329329
frameon=True,
330330
sharex=None, # use Axes instance's xaxis info
331331
sharey=None, # use Axes instance's yaxis info
332-
label='',
333-
xscale=None,
334-
yscale=None,
335332
**kwargs
336333
):
337334
"""
@@ -412,7 +409,8 @@ def __init__(self, fig, rect,
412409
#warnings.warn(
413410
# 'shared axes: "adjustable" is being changed to "datalim"')
414411
self._adjustable = 'datalim'
415-
self.set_label(label)
412+
413+
kwargs.setdefault('label','')
416414
self.set_figure(fig)
417415

418416
self.set_axes_locator(kwargs.get("axes_locator", None))
@@ -422,14 +420,18 @@ def __init__(self, fig, rect,
422420
# this call may differ for non-sep axes, eg polar
423421
self._init_axis()
424422

423+
# These duplicate parameters should be removed.
424+
## axisbg ~ axis_bgcolor (shouln't actually be axes?)
425+
## frameon == frame_on
425426
if axisbg is None:
426427
axisbg = rcParams['axes.facecolor']
427-
self._axisbg = axisbg
428-
self._frameon = frameon
428+
## push both to kwargs, which will be processed by update.
429+
## _axisbg must be assignd before cla().
430+
self._axisbg = kwargs.setdefault('axis_bgcolor', axisbg)
431+
kwargs.setdefault('frame_on', frameon)
429432
self._axisbelow = rcParams['axes.axisbelow']
430433

431434
self._rasterization_zorder = None
432-
433435
self._hold = rcParams['axes.hold']
434436
self._connected = {} # a dict from events to (id, func)
435437
self.cla()
@@ -443,10 +445,6 @@ def __init__(self, fig, rect,
443445
self.set_navigate(True)
444446
self.set_navigate_mode(None)
445447

446-
if xscale:
447-
self.set_xscale(xscale)
448-
if yscale:
449-
self.set_yscale(yscale)
450448

451449
if len(kwargs):
452450
self.update(kwargs)

0 commit comments

Comments
 (0)