最简单的柱状代码应该是这样的
# coding: utf-8import matplotlib.pyplot as pltimport numpy as np
x = np.random.randint(0, 10, size=10)
y = np.random.randint(100, 1000, size=10)
plt.bar(x, y)
plt.show()
plt.bar(x, y, yerr=[0.1,0.1,0.2,0.2,0.2], capsize=5)
plt.show()
这个工是误差棒,由yerr决定长度,两横的长度由capsize决定