四部电影三天内的票房统计
# coding=utf-8
from matplotlib import pyplot as plt
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname='C:/Windows/Fonts/simfang.ttf')
x = ['猩球崛起3:终极之战', '敦刻尔克', '蜘蛛侠:英雄归来', '战狼2']
y_14 = [15746, 312, 4497, 319]
y_15 = [12357, 156, 2045, 168]
y_16 = [2358, 339, 2358, 362]
bar_with = 0.2
x_14 = list(range(len(x)))
x_15 = [i+bar_with for i in x_14]
x_16 = [i+2*bar_with for i in x_14]
plt.figure(figsize=(20, 10), dpi=80)
plt.xticks(x_15, x, fontproperties=my_font)
plt.bar(x_14, y_14, width=bar_with, label='9月14日')
plt.bar(x_15, y_15, width=bar_with, label='9月15日')
plt.bar(x_16, y_16, width=bar_with, label='9月16日')
plt.xlabel('电影', fontproperties=my_font)
plt.ylabel('票房/万元', fontproperties=my_font)
plt.legend(prop=my_font)
plt.show()
效果图:
![](https://img2020.cnblogs.com/blog/1770885/202003/1770885-20200320143332388-95668916.png)