Matplotlib之条形图2

# coding=utf-8
# 绘制横着的条形图

from matplotlib import pyplot as plt
from matplotlib import font_manager

# 中文编码
my_font = font_manager.FontProperties(fname="/System/Library/Fonts/PingFang.ttc")

plt.figure(figsize=(20, 8), dpi=80)


x = ["战狼2","速度与激情8","功夫瑜伽","西游伏妖篇","变形金刚5:最后的骑士","摔跤吧!爸爸","加勒比海盗5:死无对证","金刚:骷髅岛","极限特工:终极回归","生化危机6:终章","乘风破浪","神偷奶爸3","智取威虎山","大闹天竺","金刚狼3:殊死一战","蜘蛛侠:英雄归来","悟空传","银河护卫队2","情圣","新木乃伊",]

y=[56.01,26.94,17.53,16.49,15.45,12.96,11.8,11.61,11.28,11.12,10.49,10.3,8.75,7.55,7.32,6.99,6.88,6.86,6.58,6.23]

plt.barh(range(len(x)), y, height=0.3,color="orange")

plt.yticks(range(len(x)), x, fontproperties=my_font)
# plt.xticks(range(max(y)),y)
plt.grid(alpha=0.3)
plt.show()

横向折线图:

发布了124 篇原创文章 · 获赞 11 · 访问量 4万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览