python之matplotlib中pyplot模块
#vertial
from matplotlib import pyplot as plt
from matplotlib import font_manager
# windows下设置中文字体
# fname的路径要参照自己电脑的路径进行
# mac与其他linux版本请自行查找
my_font=font_manager.FontProperties(fname="C:\Windows\Fonts\")
# 设置数据
a = ["战狼2","速度与激情8\n","功夫瑜伽","西游伏妖篇","变形金刚5\n:最后的骑士","摔跤吧!\n爸爸","加勒比海盗5:\n死无对证","金刚:\n骷髅岛","极限特工:\n终极回归","生化危机6:\n终章","乘风破浪","神偷奶爸3","智取威虎山","大闹天竺","金刚狼3:\n殊死一战","蜘蛛侠:\n英雄归来","悟空传","银河护卫队2","情圣","新木乃伊",]
b=[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.figure(figsize=(20,15),dpi=80)
# 设置y轴标签
plt.yticks(range(len(a)),a,fontproperties=my_font)
# 绘制网格
plt.grid(alpha=0.3)
# 绘制横直方图
plt.barh(range(len(a)),b,height=0.3,color='cyan')
# 保存图片
# ("./")
# 展示图片
plt.show()