多次条形图
四部电影三天内的票房统计
# 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()
效果图:
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步