举例三个电影三天票房的对比情况
from matplotlib import pyplot as plt
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="C:\Windows\Fonts\SimSun.ttc")
a = ["猩球崛起3:终局之战","顿刻尔克","蜘蛛侠:英雄归来","战狼2"]
b_14 = [2358,399,2358,362]
b_15 = [12357,156,2045,168]
b_16 = [15746,312,4497,319]
x_14 = list(range(len(a)))
x_15 = [i+0.2 for i in x_14]
x_16 = [i+0.4 for i in x_14]
# 设置图形大小
plt.figure(figsize=(20,8),dpi=80)
plt.bar(range(len(a)),b_14,width=0.2,label="9月14号")
plt.bar(x_15,b_15,width=0.2,label="9月15号")
plt.bar(x_16,b_16,width=0.2,label="9月16号")
# 设置x轴的刻度
plt.xticks(x_15,a,fontproperties=my_font)
# 设置图例
plt.legend(prop=my_font)
# 展示
plt.show()