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

Skip to content

Commit f7b2217

Browse files
committed
Simplify example.
Remove plot of exact PDF since this is already demoed in another example.
1 parent 6d1b8a2 commit f7b2217

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

examples/pylab_examples/histogram_demo_histtypes.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,20 @@
77
"""
88
import numpy as np
99
import matplotlib.pyplot as plt
10-
from matplotlib import mlab
1110

1211

1312
mu = 200
1413
sigma = 25
15-
n_bins = 50
1614
x = mu + sigma*np.random.randn(10000)
1715

1816
fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(8, 4))
1917

20-
n, bins, patches = ax0.hist(x, n_bins, normed=1, histtype='stepfilled',
21-
facecolor='g', alpha=0.75)
22-
# Add a line showing the expected distribution.
23-
y = mlab.normpdf(bins, mu, sigma)
24-
ax0.plot(bins, y, 'k--', linewidth=1.5)
18+
ax0.hist(x, 20, normed=1, histtype='stepfilled', facecolor='g', alpha=0.75)
2519
ax0.set_title('stepfilled')
2620

2721
# Create a histogram by providing the bin edges (unequally spaced).
2822
bins = [100, 150, 180, 195, 205, 220, 250, 300]
29-
n, bins, patches = ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8)
23+
ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8)
3024
ax1.set_title('unequal bins')
3125

3226
plt.tight_layout()

0 commit comments

Comments
 (0)