Skip to content

Commit 863502e

Browse files
committed
Added unit test to verify axes limits in Axes.fill_between
1 parent cb9b2ef commit 863502e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8558,3 +8558,19 @@ def test_ecdf_invalid():
85588558
plt.ecdf([1, np.nan])
85598559
with pytest.raises(ValueError):
85608560
plt.ecdf(np.ma.array([1, 2], mask=[True, False]))
8561+
8562+
8563+
def test_fill_between_axes_limits():
8564+
fig, ax = plt.subplots()
8565+
x = np.arange(0, 4 * np.pi, 0.01)
8566+
y = 0.1*np.sin(x)
8567+
threshold = 0.075
8568+
ax.plot(x, y, color='black')
8569+
8570+
original_lims = (ax.get_xlim(), ax.get_ylim())
8571+
8572+
ax.axhline(threshold, color='green', lw=2, alpha=0.7)
8573+
ax.fill_between(x, 0, 1, where=y > threshold,
8574+
color='green', alpha=0.5, transform=ax.get_xaxis_transform())
8575+
8576+
assert (ax.get_xlim(), ax.get_ylim()) == original_lims

0 commit comments

Comments
 (0)