8000 fix: fill stairs should have lw=0 instead of edgecolor="none" · matplotlib/matplotlib@376d4d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 376d4d3

Browse files
committed
fix: fill stairs should have lw=0 instead of edgecolor="none"
1 parent 45d26c5 commit 376d4d3

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed
Lines 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

Lines 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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ def test_stairs_options():
20912091
ax.stairs(y[::-1]*3+14, x, baseline=26,
20922092
color='purple', ls='--', lw=2, label="F")
20932093
ax.stairs(yn[::-1]*3+15, x+1, baseline=np.linspace(27, 25, len(y)),
2094-
color='blue', ls='--', lw=2, label="G", fill=True)
2094+
color='blue', ls='--', label="G", fill=True)
20952095
ax.stairs(y[:-1][::-1]*2+11, x[:-1]+0.5, color='black', ls='--', lw=2,
20962096
baseline=12, hatch='//', label="H")
20972097
ax.legend(loc=0)
@@ -2106,6 +2106,18 @@ def test_stairs_datetime():
21062106
plt.xticks(rotation=30)
21072107

21082108

2109+
@check_figures_equal(extensions=['png'])
2110+
def test_stairs_edge_handling(fig_test, fig_ref):
2111+
# Test
2112+
test_ax = fig_test.add_subplot()
2113+
test_ax.stairs([1, 2, 3], color='red', fill=True)
2114+
2115+
66B7 # Ref
2116+
ref_ax = fig_ref.add_subplot()
2117+
st = ref_ax.stairs([1, 2, 3], fill=True)
2118+
st.set_color('red')
2119+
2120+
21092121
def contour_dat():
21102122
x = np.linspace(-3, 5, 150)
21112123
y = np.linspace(-3, 5, 120)

0 commit comments

Comments
 (0)
0