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

Skip to content

Commit 746d466

Browse files
committed
TST: add test for clip and masking of negative values on log scale
- bug reports from #9288 - bug report from #9457 - demo of errorbars going negative
1 parent 6357245 commit 746d466

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/matplotlib/tests/test_scale.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,29 @@ def test_extra_kwargs_raise():
7373
with pytest.raises(ValueError):
7474
ax.set_yscale('log', nonpos='mask')
7575

76+
77+
@image_comparison(baseline_images=['logscale_nonpos_values'], remove_text=True,
78+
extensions=['png'], style='mpl20')
79+
def test_logscale_nonpos_values():
80+
np.random.seed(19680801)
81+
xs = np.random.normal(size=int(1e3))
82+
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
83+
ax1.hist(xs, range=(-5, 5), bins=10)
84+
ax1.set_yscale('log')
85+
ax2.hist(xs, range=(-5, 5), bins=10)
86+
ax2.set_yscale('log', nonposy='mask')
87+
88+
xdata = np.arange(0, 10, 0.01)
89+
ydata = np.exp(-xdata)
90+
edata = 0.2*(10-xdata)*np.cos(5*xdata)*np.exp(-xdata)
91+
92+
ax3.fill_between(xdata, ydata - edata, ydata + edata)
93+
ax3.set_yscale('log')
94+
95+
x = np.logspace(-1, 1)
96+
y = x ** 3
97+
yerr = x**2
98+
ax4.errorbar(x, y, yerr=yerr)
99+
100+
ax4.set_yscale('log')
101+
ax4.set_xscale('log')

0 commit comments

Comments
 (0)