Skip to content

Commit c3e96c5

Browse files
authored
Merge pull request #18663 from andrzejnovak/stickies
fix: keep baseline scale to baseline 0 even if set to None
2 parents 8fb850e + 5cfff94 commit c3e96c5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/matplotlib/axes/_axes.py

+2
Original file line numberDiff line numberDiff line change
@@ -6800,8 +6800,10 @@ def stairs(self, values, edges=None, *,
68006800
baseline = 0
68016801
if orientation == 'vertical':
68026802
patch.sticky_edges.y.append(np.min(baseline))
6803+
self.update_datalim([(edges[0], np.min(baseline))])
68036804
else:
68046805
patch.sticky_edges.x.append(np.min(baseline))
6806+
self.update_datalim([(np.min(baseline), edges[0])])
68056807
self._request_autoscale_view()
68066808
return patch
68076809

lib/matplotlib/tests/test_axes.py

+13
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,19 @@ def test_stairs_update(fig_test, fig_ref):
19081908
ref_ax.set_ylim(ylim)
19091909

19101910

1911+
@check_figures_equal(extensions=['png'])
1912+
def test_stairs_baseline_0(fig_test, fig_ref):
1913+
# Test
1914+
test_ax = fig_test.add_subplot()
1915+
test_ax.stairs([5, 6, 7], baseline=None)
1916+
1917+
# Ref
1918+
ref_ax = fig_ref.add_subplot()
1919+
style = {'solid_joinstyle': 'miter', 'solid_capstyle': 'butt'}
1920+
ref_ax.plot(range(4), [5, 6, 7, 7], drawstyle='steps-post', **style)
1921+
ref_ax.set_ylim(0, None)
1922+
1923+
19111924
def test_stairs_invalid_nan():
19121925
with pytest.raises(ValueError, match='Nan values in "edges"'):
19131926
plt.stairs([1, 2], [0, np.nan, 1])

0 commit comments

Comments
 (0)