import matplotlib.pyplot as plt
import numpy as np
x = np.arange(10)
y = 2**x + 10
plt.bar(x,y) #直方图显示
plt.show()
x = np.arange(10)
y = 2**x + 10
plt.bar(x,-y) #反向显示
plt.show()
x = np.arange(10)
y = 2**x + 10
plt.bar(x,y,facecolor='#9999ff',edgecolor='white') #颜色调整
plt.show()
x = np.arange(10)
y = 2**x + 10
plt.bar(x,y,facecolor='#9999ff',edgecolor='white') #facecolor设置直方颜色,edgecolor设置边框颜色
for x,y in zip(x,y): #zip将Xy结合为一个整体,同时读取
plt.text(x+0.4,y,'%.2f' % y,ha='center',va='bottom') #显示直方图的数值 位于行中心,列上方
plt.show()