Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4a3c5d6

Browse filesBrowse files
authored
Merge pull request #22559 from andrzejnovak/fix_stairs_lw
FIX: fill stairs should have lw=0 instead of edgecolor="none"
2 parents 0359832 + 376d4d3 commit 4a3c5d6
Copy full SHA for 4a3c5d6

File tree

3 files changed

+23
-2
lines changed
Filter options

3 files changed

+23
-2
lines changed
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
stairs(..., fill=True) to hide patch edge by setting lw=0
2+
---------------------------------------------------------
3+
4+
``stairs(..., fill=True)`` would previously hide Patch
5+
edge by setting edgecolor="none". Calling ``set_color()``
6+
on the Patch after would make the Patch appear larger.
7+
Updated treatment prevents this. Likewise calling
8+
``stairs(..., fill=True, lw=3)`` will behave more
9+
transparently.

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6825,7 +6825,7 @@ def stairs(self, values, edges=None, *,
68256825
else:
68266826
_color = self._get_lines.get_next_color()
68276827
if fill:
6828-
kwargs.setdefault('edgecolor', 'none')
6828+
kwargs.setdefault('linewidth', 0)
68296829
kwargs.setdefault('facecolor', _color)
68306830
else:
68316831
kwargs.setdefault('edgecolor', _color)

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ def test_stairs_options():
20952095
ax.stairs(y[::-1]*3+14, x, baseline=26,
20962096
color='purple', ls='--', lw=2, label="F")
20972097
ax.stairs(yn[::-1]*3+15, x+1, baseline=np.linspace(27, 25, len(y)),
2098-
color='blue', ls='--', lw=2, label="G", fill=True)
2098+
color='blue', ls='--', label="G", fill=True)
20992099
ax.stairs(y[:-1][::-1]*2+11, x[:-1]+0.5, color='black', ls='--', lw=2,
21002100
baseline=12, hatch='//', label="H")
21012101
ax.legend(loc=0)
@@ -2110,6 +2110,18 @@ def test_stairs_datetime():
21102110
plt.xticks(rotation=30)
21112111

21122112

2113+
@check_figures_equal(extensions=['png'])
2114+
def test_stairs_edge_handling(fig_test, fig_ref):
2115+
# Test
2116+
test_ax = fig_test.add_subplot()
2117+
test_ax.stairs([1, 2, 3], color='red', fill=True)
2118+
2119+
# Ref
2120+
ref_ax = fig_ref.add_subplot()
2121+
st = ref_ax.stairs([1, 2, 3], fill=True)
2122+
st.set_color('red')
2123+
2124+
21132125
def contour_dat():
21142126
x = np.linspace(-3, 5, 150)
21152127
y = np.linspace(-3, 5, 120)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.