|
7 | 7 | """ |
8 | 8 | import numpy as np |
9 | 9 | import matplotlib.pyplot as plt |
10 | | -from matplotlib import mlab |
11 | 10 |
|
12 | 11 |
|
13 | 12 | mu = 200 |
14 | 13 | sigma = 25 |
15 | | -n_bins = 50 |
16 | 14 | x = mu + sigma*np.random.randn(10000) |
17 | 15 |
|
18 | 16 | fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(8, 4)) |
19 | 17 |
|
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) |
25 | 19 | ax0.set_title('stepfilled') |
26 | 20 |
|
27 | 21 | # Create a histogram by providing the bin edges (unequally spaced). |
28 | 22 | 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) |
30 | 24 | ax1.set_title('unequal bins') |
31 | 25 |
|
32 | 26 | plt.tight_layout() |
|
0 commit comments