2024年Python最全Python matplotlib seaborn(学习笔记)

该文章介绍了使用Python进行中国电影票房数据的统计和可视化,包括2021年票房top10的线图、条形图、直方图以及不同类型电影的详细分析。作者展示了如何处理大量Excel数据,并通过各种图表展示票房与人次、价格的关系。
摘要由CSDN通过智能技术生成

plt.figure(figsize=(14,8))

plt.title(“中国电影票房2021top10”)

plt.xlabel(“电影名称”)

plt.ylabel(“电影票房”)

sns.lineplot(data=cnbo2021top5[[‘bos’]])

plt.xticks(rotation=45)

在这里插入图片描述

02 柱形图


cnbo2021top5ftgb=cnbo2021top5.groupby([‘ftypes’])[‘bos’,‘persons’,‘prices’,‘points’].mean()

cnbo2021top5ftgb=cnbo2021top5ftgb.reset_index().replace()

cnbo2021top5ftgb

在这里插入图片描述

02 条形图

plt.figure(figsize=(14,8))

plt.title(“中国电影票房2021top10”)

sns.barplot(x=cnbo2021top5ftgb[‘ftypes’],y=cnbo2021top5ftgb[‘persons’])

plt.xlabel(“电影类型”)

plt.ylabel(“场均人次”)

plt.xticks(rotation=45)

plt.show()

在这里插入图片描述

03 直方图


03 直方图

plt.figure(figsize=(14,8))

plt.title(“中国电影票房2021top10”)

sns.histplot(x=cnbo2021top5[‘bos’],bins=15) # x=cnbo2021top5ftgb[‘ftypes’],y=cnbo2021top5ftgb[‘persons’]

plt.xlabel(“电影类型”)

plt.ylabel(“场均人次”)

plt.xticks(rotation=45)

plt.show()

在这里插入图片描述

三、绘图

==================================================================


上面的数据只有十部电影,而下面的数据是我整理出来的电影数据:

Excel:300部电影数据整理

import pandas as pd

cnboo=pd.read_excel(“cnboNPPD1.xlsx”)

cnboo

在这里插入图片描述

01 设定调色盘


设定调色盘

sns.set_palette(color)

sns.palplot(sns.color_palette(color,11)) # 表示11种颜色

  • 29
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值