|
1 | 1 | """ |
2 | | -This example demonstrates the "bmh" style, which is the design used in the |
3 | | -Bayesian Methods for Hackers online book. |
| 2 | +======================================== |
| 3 | +Bayesian Methods for Hackers style sheet |
| 4 | +======================================== |
| 5 | +
|
| 6 | +This example demonstrates the style used in the Bayesian Methods for Hackers |
| 7 | +[1]_ online book. |
| 8 | +
|
| 9 | +.. [1] http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/ |
| 10 | +
|
4 | 11 | """ |
5 | 12 | from numpy.random import beta |
6 | 13 | import matplotlib.pyplot as plt |
7 | 14 |
|
8 | 15 | plt.style.use('bmh') |
9 | 16 |
|
10 | 17 |
|
11 | | -def plot_beta_hist(a, b): |
12 | | - plt.hist(beta(a, b, size=10000), histtype="stepfilled", |
13 | | - bins=25, alpha=0.8, normed=True) |
14 | | - return |
| 18 | +def plot_beta_hist(ax, a, b): |
| 19 | + ax.hist(beta(a, b, size=10000), histtype="stepfilled", |
| 20 | + bins=25, alpha=0.8, normed=True) |
| 21 | + return ax |
| 22 | + |
15 | 23 |
|
16 | | -plot_beta_hist(10, 10) |
17 | | -plot_beta_hist(4, 12) |
18 | | -plot_beta_hist(50, 12) |
19 | | -plot_beta_hist(6, 55) |
| 24 | +fig, ax = plt.subplots() |
| 25 | +plot_beta_hist(ax, 10, 10) |
| 26 | +plot_beta_hist(ax, 4, 12) |
| 27 | +plot_beta_hist(ax, 50, 12) |
| 28 | +plot_beta_hist(ax, 6, 55) |
| 29 | +ax.set_title("'bmh' style sheet") |
20 | 30 |
|
21 | 31 | plt.show() |
0 commit comments