matplotlib绘图(2)
plt.bar
colors=["#348ABD","#A60628"]
plt.bar([0,.7], prior, alpha=0.70, width=0.25, color=colors[0],
label="prior distribution", lw="3", edgecolor="#348ABD")
plt.bar([.25, .7+.25], posterior, alpha=.7, width=0.25,
color=colors[1],label="posterior dis", lw="3",edgecolor="#A60628")
plt.xticks([0.10,0.95], ["Librarian", "Farmer"])
plt.set_xlabel("string")
plt.set_ylabel("string")
实例
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
colors=["#348ABD","#A60628"]
prior = [1/21., 20/21.]
posterior = [0.087, 1-0.087]
plt.bar([0,.7], prior, alpha=0.70, width=0.25, color=colors[0],label="prior distribution", lw="3", edgecolor="#348ABD")
plt.bar([.25, .7+.25], posterior, alpha=.7, width=0.25, color=colors[1],label="posterior dis", lw="3",edgecolor="#A60628")
plt.xticks([0.10,0.95], ["Librarian", "Farmer"])
plt.title(".......")
plt.ylabel("Prob")
plt.legend(loc="upper left")