Skip to content

Commit 21e9e65

Browse files
committed
Use named kwargs for log method and fix docs
The default behaviour for the yaxis was actually 'clip', but documented as 'mask' (xaxis was correctly documented as 'mask').
1 parent 623b98d commit 21e9e65

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

lib/matplotlib/axes/_axes.py

+16-27
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,10 @@ def plot_date(self, x, y, fmt='o', tz=None, xdate=True, ydate=False,
14331433

14341434
# @_preprocess_data() # let 'plot' do the unpacking..
14351435
@docstring.dedent_interpd
1436-
def loglog(self, *args, **kwargs):
1436+
def loglog(self, *args,
1437+
basex=10, subsx=None, nonposx='mask',
1438+
basey=10, subsy=None, nonposy='clip',
1439+
**kwargs):
14371440
"""
14381441
Make a plot with log scaling on both the x and y axis.
14391442
@@ -1461,9 +1464,10 @@ def loglog(self, *args, **kwargs):
14611464
decades in the plot.
14621465
See `.Axes.set_xscale` / `.Axes.set_yscale` for details.
14631466
1464-
nonposx, nonposy : {'mask', 'clip'}, optional, default 'mask'
1467+
nonposx, nonposy : {'mask', 'clip'}, optional
14651468
Non-positive values in x or y can be masked as invalid, or clipped
14661469
to a very small positive number.
1470+
Default 'mask' for xaxis and 'clip' for yaxis.
14671471
14681472
Returns
14691473
-------
@@ -1475,20 +1479,13 @@ def loglog(self, *args, **kwargs):
14751479
**kwargs
14761480
All parameters supported by `.plot`.
14771481
"""
1478-
dx = {k: kwargs.pop(k) for k in ['basex', 'subsx', 'nonposx']
1479-
if k in kwargs}
1480-
dy = {k: kwargs.pop(k) for k in ['basey', 'subsy', 'nonposy']
1481-
if k in kwargs}
1482-
1483-
self.set_xscale('log', **dx)
1484-
self.set_yscale('log', **dy)
1485-
1486-
l = self.plot(*args, **kwargs)
1487-
return l
1482+
self.set_xscale('log', basex=basex, subsx=subsx, nonposx=nonposx)
1483+
self.set_yscale('log', basey=basey, subsy=subsy, nonposy=nonposy)
1484+
return self.plot(*args, **kwargs)
14881485

14891486
# @_preprocess_data() # let 'plot' do the unpacking..
14901487
@docstring.dedent_interpd
1491-
def semilogx(self, *args, **kwargs):
1488+
def semilogx(self, *args, basex=10, subsx=None, nonposx='mask', **kwargs):
14921489
"""
14931490
Make a plot with log scaling on the x axis.
14941491
@@ -1528,16 +1525,12 @@ def semilogx(self, *args, **kwargs):
15281525
**kwargs
15291526
All parameters supported by `.plot`.
15301527
"""
1531-
d = {k: kwargs.pop(k) for k in ['basex', 'subsx', 'nonposx']
1532-
if k in kwargs}
1533-
1534-
self.set_xscale('log', **d)
1535-
l = self.plot(*args, **kwargs)
1536-
return l
1528+
self.set_xscale('log', basex=basex, subsx=subsx, nonposx=nonposx)
1529+
return self.plot(*args, **kwargs)
15371530

15381531
# @_preprocess_data() # let 'plot' do the unpacking..
15391532
@docstring.dedent_interpd
1540-
def semilogy(self, *args, **kwargs):
1533+
def semilogy(self, *args, basey=10, subsy=None, nonposy='clip', **kwargs):
15411534
"""
15421535
Make a plot with log scaling on the y axis.
15431536
@@ -1563,7 +1556,7 @@ def semilogy(self, *args, **kwargs):
15631556
are automatically chosen depending on the number of decades in the
15641557
plot. See `.Axes.set_yscale` for details.
15651558
1566-
nonposy : {'mask', 'clip'}, optional, default 'mask'
1559+
nonposy : {'mask', 'clip'}, optional, default 'clip'
15671560
Non-positive values in y can be masked as invalid, or clipped to a
15681561
very small positive number.
15691562
@@ -1577,12 +1570,8 @@ def semilogy(self, *args, **kwargs):
15771570
**kwargs
15781571
All parameters supported by `.plot`.
15791572
"""
1580-
d = {k: kwargs.pop(k) for k in ['basey', 'subsy', 'nonposy']
1581-
if k in kwargs}
1582-
self.set_yscale('log', **d)
1583-
l = self.plot(*args, **kwargs)
1584-
1585-
return l
1573+
self.set_yscale('log', basey=basey, subsy=subsy, nonposy=nonposy)
1574+
return self.plot(*args, **kwargs)
15861575

15871576
@_preprocess_data(replace_names=["x"], label_namer="x")
15881577
def acorr(self, x, **kwargs):

0 commit comments

Comments
 (0)