Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4c24f2

Browse files
authored
Merge pull request #10014 from jklymak/fix-nonposxy-log
FIX: pass nonposx/y args through loglog etc
2 parents 8f3f7ac + 57be181 commit d4c24f2

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,12 +1500,10 @@ def loglog(self, *args, **kwargs):
15001500
if not self._hold:
15011501
self.cla()
15021502

1503-
dx = {'basex': kwargs.pop('basex', 10),
1504-
'subsx': kwargs.pop('subsx', None),
1505-
}
1506-
dy = {'basey': kwargs.pop('basey', 10),
1507-
'subsy': kwargs.pop('subsy', None),
1508-
}
1503+
dx = {k: kwargs.pop(k) for k in ['basex', 'subsx', 'nonposx']
1504+
if k in kwargs}
1505+
dy = {k: kwargs.pop(k) for k in ['basey', 'subsy', 'nonposy']
1506+
if k in kwargs}
15091507

15101508
self.set_xscale('log', **dx)
15111509
self.set_yscale('log', **dy)
@@ -1560,9 +1558,8 @@ def semilogx(self, *args, **kwargs):
15601558
"""
15611559
if not self._hold:
15621560
self.cla()
1563-
d = {'basex': kwargs.pop('basex', 10),
1564-
'subsx': kwargs.pop('subsx', None),
1565-
}
1561+
d = {k: kwargs.pop(k) for k in ['basex', 'subsx', 'nonposx']
1562+
if k in kwargs}
15661563

15671564
self.set_xscale('log', **d)
15681565
b = self._hold
@@ -1615,9 +1612,8 @@ def semilogy(self, *args, **kwargs):
16151612

16161613
if not self._hold:
16171614
self.cla()
1618-
d = {'basey': kwargs.pop('basey', 10),
1619-
'subsy': kwargs.pop('subsy', None),
1620-
}
1615+
d = {k: kwargs.pop(k) for k in ['basey', 'subsy', 'nonposy']
1616+
if k in kwargs}
16211617
self.set_yscale('log', **d)
16221618
b = self._hold
16231619
self._hold = True # we've already processed the hold

lib/matplotlib/tests/test_axes.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4964,6 +4964,24 @@ def test_loglog():
49644964
ax.tick_params(length=15, width=2, which='minor')
49654965

49664966

4967+
@image_comparison(baseline_images=["test_loglog_nonpos"],
4968+
remove_text=True, extensions=['png'], style='mpl20')
4969+
def test_loglog_nonpos():
4970+
fig, ax = plt.subplots(3, 3)
4971+
x = np.arange(1, 11)
4972+
y = x**3
4973+
y[7] = -3.
4974+
x[4] = -10
4975+
for nn, mcx in enumerate(['mask', 'clip', '']):
4976+
for mm, mcy in enumerate(['mask', 'clip', '']):
4977+
kws = {}
4978+
if mcx:
4979+
kws['nonposx'] = mcx
4980+
if mcy:
4981+
kws['nonposy'] = mcy
4982+
ax[mm, nn].loglog(x, y**3, lw=2, **kws)
4983+
4984+
49674985
@pytest.mark.style('default')
49684986
def test_axes_margins():
49694987
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)