#导入需要的库
import numpy as np
import matplotlib.pyplot as plt
#准备数据
x = np.arange(5)
y_a= np.array([8, 7, 7,10, 13])
y_b= np.array([14, 10, 15, 20, 17, ])
#创建代表画布的对象fig
fig = plt.figure()
ax = fig.add_subplot(111)#在画布上添加绘图区域(一行一列的第一个区域)
# 设置柱形图的宽度
bar_width = 0.2 #指定条形宽度 默认值:0.8
# 绘制柱形图
plt.bar(x, y_a, width=bar_width)
plt.bar(x + bar_width, y_b, tick_label=['a', 'b', 'c', 'd', 'e', ], width=bar_width)
plt.show()