From 344829c352c4e883fa4de14c671e3ed34f9906bd Mon Sep 17 00:00:00 2001 From: andrzejnovak Date: Mon, 5 Oct 2020 19:48:18 +0200 Subject: [PATCH 1/2] fix: update datalim in stairs --- lib/matplotlib/axes/_axes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index f9d7290fc6be..9d5fe3001624 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6793,8 +6793,10 @@ def stairs(self, values, edges=None, *, baseline = 0 if orientation == 'vertical': patch.sticky_edges.y.append(np.min(baseline)) + self.update_datalim([(edges[0], np.min(baseline))]) else: patch.sticky_edges.x.append(np.min(baseline)) + self.update_datalim([(np.min(baseline), edges[0])]) self._request_autoscale_view() return patch From 5cfff945c467cbc07c167bc3afebfee0ec1b9602 Mon Sep 17 00:00:00 2001 From: andrzejnovak Date: Tue, 6 Oct 2020 08:57:36 +0200 Subject: [PATCH 2/2] test: stairs baseline=None --- lib/matplotlib/tests/test_axes.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 336543329355..6d3050c3df8e 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -1908,6 +1908,19 @@ def test_stairs_update(fig_test, fig_ref): ref_ax.set_ylim(ylim) +@check_figures_equal(extensions=['png']) +def test_stairs_baseline_0(fig_test, fig_ref): + # Test + test_ax = fig_test.add_subplot() + test_ax.stairs([5, 6, 7], baseline=None) + + # Ref + ref_ax = fig_ref.add_subplot() + style = {'solid_joinstyle': 'miter', 'solid_capstyle': 'butt'} + ref_ax.plot(range(4), [5, 6, 7, 7], drawstyle='steps-post', **style) + ref_ax.set_ylim(0, None) + + def test_stairs_invalid_nan(): with pytest.raises(ValueError, match='Nan values in "edges"'): plt.stairs([1, 2], [0, np.nan, 1]) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy