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

Skip to content

Commit c68752b

Browse files
anntzerMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #10014: FIX: pass nonposx/y args through loglog etc
1 parent 9f17a5b commit c68752b

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
@@ -1490,12 +1490,10 @@ def loglog(self, *args, **kwargs):
14901490
if not self._hold:
14911491
self.cla()
14921492

1493-
dx = {'basex': kwargs.pop('basex', 10),
1494-
'subsx': kwargs.pop('subsx', None),
1495-
}
1496-
dy = {'basey': kwargs.pop('basey', 10),
1497-
'subsy': kwargs.pop('subsy', None),
1498-
}
1493+
dx = {k: kwargs.pop(k) for k in ['basex', 'subsx', 'nonposx']
1494+
if k in kwargs}
1495+
dy = {k: kwargs.pop(k) for k in ['basey', 'subsy', 'nonposy']
1496+
if k in kwargs}
14991497

15001498
self.set_xscale('log', **dx)
15011499
self.set_yscale('log', **dy)
@@ -1550,9 +1548,8 @@ def semilogx(self, *args, **kwargs):
15501548
"""
15511549
if not self._hold:
15521550
self.cla()
1553-
d = {'basex': kwargs.pop('basex', 10),
1554-
'subsx': kwargs.pop('subsx', None),
1555-
}
1551+
d = {k: kwargs.pop(k) for k in ['basex', 'subsx', 'nonposx']
1552+
if k in kwargs}
15561553

15571554
self.set_xscale('log', **d)
15581555
b = self._hold
@@ -1605,9 +1602,8 @@ def semilogy(self, *args, **kwargs):
16051602

16061603
if not self._hold:
16071604
self.cla()
1608-
d = {'basey': kwargs.pop('basey', 10),
1609-
'subsy': kwargs.pop('subsy', None),
1610-
}
1605+
d = {k: kwargs.pop(k) for k in ['basey', 'subsy', 'nonposy']
1606+
if k in kwargs}
16111607
self.set_yscale('log', **d)
16121608
b = self._hold
16131609
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
@@ -4876,6 +4876,24 @@ def test_loglog():
48764876
ax.tick_params(length=15, width=2, which='minor')
48774877

48784878

4879+
@image_comparison(baseline_images=["test_loglog_nonpos"],
4880+
remove_text=True, extensions=['png'], style='mpl20')
4881+
def test_loglog_nonpos():
4882+
fig, ax = plt.subplots(3, 3)
4883+
x = np.arange(1, 11)
4884+
y = x**3
4885+
y[7] = -3.
4886+
x[4] = -10
4887+
for nn, mcx in enumerate(['mask', 'clip', '']):
4888+
for mm, mcy in enumerate(['mask', 'clip', '']):
4889+
kws = {}
4890+
if mcx:
4891+
kws['nonposx'] = mcx
4892+
if mcy:
4893+
kws['nonposy'] = mcy
4894+
ax[mm, nn].loglog(x, y**3, lw=2, **kws)
4895+
4896+
48794897
@pytest.mark.style('default')
48804898
def test_axes_margins():
48814899
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)