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

Skip to content

Commit b2fd5ed

Browse files
committed
fix test_stairs_update
We have to use fixed view limits because stairs() does autoscale, but updating data does not. Otherwise the test and ref way of generating the plot would end up with different view limits.
1 parent 96ebbed commit b2fd5ed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,9 +1878,12 @@ def test_stairs_fill(fig_test, fig_ref):
18781878

18791879
@check_figures_equal(extensions=['png'])
18801880
def test_stairs_update(fig_test, fig_ref):
1881+
# fixed ylim because stairs() does autoscale, but updating data does not
1882+
ylim = -3, 4
18811883
# Test
18821884
test_ax = fig_test.add_subplot()
18831885
h = test_ax.stairs([1, 2, 3])
1886+
test_ax.set_ylim(ylim)
18841887
h.set_values([3, 2, 1])
18851888
h.set_edges(np.arange(4)+2)
18861889
h.set_data([1, 2, 1], np.arange(4)/2)
@@ -1891,9 +1894,10 @@ def test_stairs_update(fig_test, fig_ref):
18911894
h.set_baseline(-2)
18921895
assert h.get_baseline() == -2
18931896

1894-
# # Ref
1897+
# Ref
18951898
ref_ax = fig_ref.add_subplot()
18961899
h = ref_ax.stairs([1, 2, 3], baseline=-2)
1900+
ref_ax.set_ylim(ylim)
18971901

18981902

18991903
def test_stairs_invalid_nan():

0 commit comments

Comments
 (0)