Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d32ed0

Browse files
committed
Add hatch, linewidth and edgecolor parameters to multihist example
1 parent 49cbec6 commit 7d32ed0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

galleries/examples/statistics/histogram_multihist.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,24 @@
2727
fig, ((ax0, ax1), (ax2, ax3)) = plt.subplots(nrows=2, ncols=2)
2828

2929
colors = ['red', 'tan', 'lime']
30-
ax0.hist(x, n_bins, density=True, histtype='bar', color=colors, label=colors)
30+
ax0.hist(x, n_bins, density=True, histtype='bar', color=colors,
31+
label=colors, hatch=['o', '*', '.'],
32+
edgecolor=['black', 'red', 'blue'], linewidth=[1, 2, 3])
3133
ax0.legend(prop={'size': 10})
3234
ax0.set_title('bars with legend')
3335

34-
ax1.hist(x, n_bins, density=True, histtype='bar', stacked=True)
36+
ax1.hist(
37+
x, n_bins, density=True, histtype="bar", stacked=True,
38+
edgecolor=["black", "yellow", "blue"])
3539
ax1.set_title('stacked bar')
3640

37-
ax2.hist(x, n_bins, histtype='step', stacked=True, fill=False)
41+
ax2.hist(x, n_bins, histtype='step', stacked=True, fill=False,
42+
linewidth=[1, 2, 3])
3843
ax2.set_title('stack step (unfilled)')
3944

4045
# Make a multiple-histogram of data-sets with different length.
4146
x_multi = [np.random.randn(n) for n in [10000, 5000, 2000]]
42-
ax3.hist(x_multi, n_bins, histtype='bar')
47+
ax3.hist(x_multi, n_bins, histtype='bar', hatch=['\\', '/', '-'])
4348
ax3.set_title('different sample sizes')
4449

4550
fig.tight_layout()

0 commit comments

Comments
 (0)