Skip to content

Commit 1e4eb2e

Browse files
committed
Make edgecolors and facecolors the same when using stepfilled histogram.
Closes matplotlib#6493
1 parent 14664e2 commit 1e4eb2e

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6281,24 +6281,17 @@ def _normalize_input(inp, ename='input'):
62816281
xvals.append(x.copy())
62826282
yvals.append(y.copy())
62836283

6284-
if fill:
6285-
# add patches in reverse order so that when stacking,
6286-
# items lower in the stack are plottted on top of
6287-
# items higher in the stack
6288-
for x, y, c in reversed(list(zip(xvals, yvals, color))):
6289-
patches.append(self.fill(
6290-
x, y,
6291-
closed=True,
6292-
facecolor=c,
6293-
margins=margins))
6294-
else:
6295-
for x, y, c in reversed(list(zip(xvals, yvals, color))):
6296-
split = 2 * len(bins)
6297-
patches.append(self.fill(
6298-
x[:split], y[:split],
6299-
closed=False, edgecolor=c,
6300-
fill=False,
6301-
margins=margins))
6284+
# add patches in reverse order so that when stacking,
6285+
# items lower in the stack are plottted on top of
6286+
# items higher in the stack
6287+
split = 2 * len(bins)
6288+
for x, y, c in reversed(list(zip(xvals, yvals, color))):
6289+
patches.append(self.fill(
6290+
x[:split], y[:split],
6291+
closed=False,
6292+
edgecolor=c,
6293+
facecolor=c,
6294+
margins=margins))
63026295

63036296
# we return patches, so put it back in the expected order
63046297
patches.reverse()
Loading

lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,16 @@ def test_hist_steplog():
11511151
plt.hist(data_big, 100, histtype='stepfilled', log=True, orientation='horizontal')
11521152

11531153

1154+
@image_comparison(baseline_images=['hist_step_filled'], extensions=['png'])
1155+
def test_hist_step_empty():
1156+
np.random.seed(0)
1157+
x = np.random.randn(1000, 3)
1158+
fig, ax = plt.subplots()
1159+
ax.hist(x, n_bins, histtype='step', fill=True, stacked=True)
1160+
patches= ax.patches
1161+
all([p.get_facecolor() == p.get_edgecolor() for p in patches])
1162+
1163+
11541164
@image_comparison(baseline_images=['hist_step_log_bottom'],
11551165
remove_text=True, extensions=['png'])
11561166
def test_hist_step_log_bottom():

0 commit comments

Comments
 (0)