Skip to content

Commit

Permalink
Make edgecolors and facecolors the same when using stepfilled histogram.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed May 29, 2016
1 parent 14664e2 commit 1e4eb2e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
29 changes: 11 additions & 18 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -6281,24 +6281,17 @@ def _normalize_input(inp, ename='input'):
xvals.append(x.copy())
yvals.append(y.copy())

if fill:
# add patches in reverse order so that when stacking,
# items lower in the stack are plottted on top of
# items higher in the stack
for x, y, c in reversed(list(zip(xvals, yvals, color))):
patches.append(self.fill(
x, y,
closed=True,
facecolor=c,
margins=margins))
else:
for x, y, c in reversed(list(zip(xvals, yvals, color))):
split = 2 * len(bins)
patches.append(self.fill(
x[:split], y[:split],
closed=False, edgecolor=c,
fill=False,
margins=margins))
# add patches in reverse order so that when stacking,
# items lower in the stack are plottted on top of
# items higher in the stack
split = 2 * len(bins)
for x, y, c in reversed(list(zip(xvals, yvals, color))):
patches.append(self.fill(
x[:split], y[:split],
closed=False,
edgecolor=c,
facecolor=c,
margins=margins))

# we return patches, so put it back in the expected order
patches.reverse()
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -1151,6 +1151,16 @@ def test_hist_steplog():
plt.hist(data_big, 100, histtype='stepfilled', log=True, orientation='horizontal')


@image_comparison(baseline_images=['hist_step_filled'], extensions=['png'])
def test_hist_step_empty():
np.random.seed(0)
x = np.random.randn(1000, 3)
fig, ax = plt.subplots()
ax.hist(x, n_bins, histtype='step', fill=True, stacked=True)
patches= ax.patches
all([p.get_facecolor() == p.get_edgecolor() for p in patches])


@image_comparison(baseline_images=['hist_step_log_bottom'],
remove_text=True, extensions=['png'])
def test_hist_step_log_bottom():
Expand Down

0 comments on commit 1e4eb2e

Please sign in to comment.