# -*- conding utf-8 -*-
# 作者：彭静
# 开发时间:下午 12:02
# 开发工具:PyCharm
# 条形图:离散数据（数据之间没有任何关系）
# 2017年内地电影票房前20的电影和电影票房数据
# a = ["战狼2"，"速度与激情8","功夫瑜伽","西游伏妖篇","变形金刚5","最后的骑士","摔跤吧！爸爸","加勒比海盗5","死无对证","金刚","骷髅头","极限特工","终极回归","生化危机6:终章","乘风破浪","神偷奶爸3","
# 智取威虎山","大闹天竺","金刚狼3:殊死一战","蜘蛛侠:英雄归来","悟空传","银河护卫队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]
# 单位：亿
from matplotlib import pyplot as plt

# 设置字体中文出现错误
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

a = ["战狼2","速度与激情8","功夫瑜伽","西游伏妖篇","变形金刚5:最后的骑士","摔跤吧！爸爸","加勒比海盗5:死无对证",
     "金刚:骷髅头","极限特工:终极回归","生化危机6:终章","乘风破浪","神偷奶爸3","智取威虎山","大闹天竺","金刚狼3:殊死一战",
     "蜘蛛侠:英雄归来","悟空传","银河护卫队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]
# print(len(a),len(b))


plt.barh(range(len(a)),b,height=0.3)


plt.yticks(range(len(a)),a)

plt.ylabel("电影")
plt.xlabel("票房（亿元）")
plt.title('2017年内地电影票房前20的电影')
# plt.grid()
plt.show()