注意
前往結尾以下載完整的範例程式碼。
駭客貝氏方法樣式表#
此範例示範了駭客貝氏方法[1]線上書籍中使用的樣式。

import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
plt.style.use('bmh')
def plot_beta_hist(ax, a, b):
ax.hist(np.random.beta(a, b, size=10000),
histtype="stepfilled", bins=25, alpha=0.8, density=True)
fig, ax = plt.subplots()
plot_beta_hist(ax, 10, 10)
plot_beta_hist(ax, 4, 12)
plot_beta_hist(ax, 50, 12)
plot_beta_hist(ax, 6, 55)
ax.set_title("'bmh' style sheet")
plt.show()