Skip to content

Commit ecc54cb

Browse files
committed
fix: minor StepPatch adjustments
1 parent 4018a62 commit ecc54cb

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

doc/users/next_whats_new/steppatch_and_stairs.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
New `~.matplotlib.patches.StepPatch` artist and a `.pyplot.stairs` method
2-
-------------------------------------------------------------------------
1+
New StepPatch artist and a stairs method
2+
----------------------------------------
3+
New `~.matplotlib.patches.StepPatch` artist and `.pyplot.stairs` method.
34
For both the artist and the function, the x-like edges input is one
45
longer than the y-like values input
56

lib/matplotlib/patches.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,8 @@ def _update_path(self):
10281028
if self._edges.size - 1 != self._values.size:
10291029
raise ValueError('Size mismatch between "values" and "edges". '
10301030
"Expected `len(values) + 1 == len(edges)`, but "
1031-
"they are or lengths {} and {}".format(
1032-
self._edges.size, self._values.size)
1033-
)
1031+
f"`len(values) = {self._values.size}` and "
1032+
f"`len(edges) = {self._edges.size}`.")
10341033
verts, codes = [], []
10351034
for idx0, idx1 in cbook.contiguous_regions(~np.isnan(self._values)):
10361035
x = np.repeat(self._edges[idx0:idx1+1], 2)

lib/matplotlib/tests/test_axes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1847,14 +1847,14 @@ def test_stairs_invalid_mismatch():
18471847

18481848
@pytest.mark.xfail
18491849
def test_stairs_invalid_update():
1850-
h = plt.stairs([1, 2], [0, 1])
1851-
h.set_edges(np.arange(5))
1850+
h = plt.stairs([1, 2], [0, 1, 2])
1851+
h.set_edges([1, np.nan, 2])
18521852

18531853

18541854
@pytest.mark.xfail
18551855
def test_stairs_invalid_update2():
1856-
h = plt.stairs([1, 2], [0, 1])
1857-
h.set_edges([1, np.nan, 2])
1856+
h = plt.stairs([1, 2], [0, 1, 2])
1857+
h.set_edges(np.arange(5))
18581858

18591859

18601860
@image_comparison(['test_stairs_options.png'], remove_text=True)

0 commit comments

Comments
 (0)