python使用matplotlib画图之多个条形图
python
it书童
2020-05-23 21:55:42
0赞
0踩
902阅读
0评论
from matplotlib import pyplot as plt
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="/System/Library/Fonts/PingFang.ttc")
# 影片
a = ['猩球崛起3:终极之战', '敦刻尔克', '蜘蛛侠:英雄归来', '战狼2']
# 票房
b_16 = [15746, 312, 4497, 319]
b_15 = [12357, 156, 2045, 168]
b_14 = [2358, 399, 2358, 362]
plt.figure(figsize=(20, 8), dpi=80)
# 条形图宽度
bar_width = 0.2
x_14 = list(range(len(a)))
x_15 = [i + bar_width for i in x_14]
x_16 = [i + bar_width * 2 for i in x_14]
plt.bar(x_14, b_14, width=bar_width, label='9月14日')
plt.bar(x_15, b_15, width=bar_width, label='9月15日')
plt.bar(x_16, b_16, width=bar_width, label='9月16日')
plt.legend(prop=my_font)
plt.xticks(x_15, a, fontproperties=my_font)
plt.show()

关于我
一个文科出身的程序员,追求做个有趣的人,传播有价值的知识,微信公众号主要分享读书思考心得,不会有代码类文章,非程序员的同学请放心订阅
转载须注明出处:https://www.itshutong.com/articles/509/python-uses-matplotlib-to-draw-multiple-bar-graphs
精品付费
个人开发者通过payjs接入微信支付
4815
0
这一次,真正掌握composer
2602
0
相关推荐
pycharm 使用技巧
4568
0
为python版本抓狂,试下pyenv吧
1275
0
pip 换成国内阿里镜像源
1592
0
pycharm 将 conda 作为环境
1032
0
python使用matplotlib画图之折线图
1146
0
python使用matplotlib画图之散点图
773
0
python使用matplotlib画图之条形图
938
0
python使用matplotlib画图之直方图
858
0