Skip to content

Commit 3b4f52e

Browse files
authored
Merge pull request #22593 from meeseeksmachine/auto-backport-of-pr-22559-on-v3.5.x
Backport PR #22559 on branch v3.5.x (fix: fill stairs should have lw=0 instead of edgecolor="none")
2 parents 0040b0a + 10e7a26 commit 3b4f52e

File tree

3 files changed

+23
-2
lines changed

3 files changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6853,7 +6853,7 @@ def stairs(self, values, edges=None, *,
68536853
else:
68546854
_color = self._get_lines.get_next_color()
68556855
if fill:
6856-
kwargs.setdefault('edgecolor', 'none')
6856+
kwargs.setdefault('linewidth', 0)
68576857
kwargs.setdefault('facecolor', _color)
68586858
else:
68596859
kwargs.setdefault('edgecolor', _color)

lib/matplotlib/tests/test_axes.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -2070,7 +2070,7 @@ def test_stairs_options():
20702070
ax.stairs(y[::-1]*3+14, x, baseline=26,
20712071
color='purple', ls='--', lw=2, label="F")
20722072
ax.stairs(yn[::-1]*3+15, x+1, baseline=np.linspace(27, 25, len(y)),
2073-
color='blue', ls='--', lw=2, label="G", fill=True)
2073+
color='blue', ls='--', label="G", fill=True)
20742074
ax.stairs(y[:-1][::-1]*2+11, x[:-1]+0.5, color='black', ls='--', lw=2,
20752075
baseline=12, hatch='//', label="H")
20762076
ax.legend(loc=0)
@@ -2085,6 +2085,18 @@ def test_stairs_datetime():
20852085
plt.xticks(rotation=30)
20862086

20872087

2088+
@check_figures_equal(extensions=['png'])
2089+
def test_stairs_edge_handling(fig_test, fig_ref):
2090+
# Test
2091+
test_ax = fig_test.add_subplot()
2092+
test_ax.stairs([1, 2, 3], color='red', fill=True)
2093+
2094+
# Ref
2095+
ref_ax = fig_ref.add_subplot()
2096+
st = ref_ax.stairs([1, 2, 3], fill=True)
2097+
st.set_color('red')
2098+
2099+
20882100
def contour_dat():
20892101
x = np.linspace(-3, 5, 150)
20902102
y = np.linspace(-3, 5, 120)

0 commit comments

Comments
 (0)