python学习 matplotlib绘制景区气温饼图,柱形图,折线图 一起敲敲键盘

import pandas
import matplotlib.pyplot
excel=pandas.read_excel("编程语言排行榜.xlsx",sheet_name=1)#读取excel文件
print(excel)

matplotlib.pyplot.rcParams['font.sans-serif']=['SimHei']#解决中文乱码 将'font.sans-serif'设置为'SimHei' Matplotlib会使用'SimHei'来渲染中文文本。

matplotlib.pyplot.figure(figsize=(10,6))#设置画布大小

#取值
keyword=excel['编程语言']
value=excel['流行度']
print(keyword)
print(value)

matplotlib.pyplot.pie(value,labels=keyword,autopct='%1.1f%%',startangle=90)#绘制饼图 %1.1f%% 保留一位小数 startangle=90 给正角度,可有可无
matplotlib.pyplot.axis('equal')#设置x轴,y轴刻度,使饼图为一个正圆
matplotlib.pyplot.title("2024 年 7 月编程语言流行度饼图")#设置标题
matplotlib.pyplot.show()

matplotlib.pyplot.figure(figsize=(25,2))#设置画布大小
matplotlib.pyplot.bar(keyword,value,width=0.8)#绘制柱形图
matplotlib.pyplot.title("2024 年 7 月编程语言流行度树状图")#设置标题
matplotlib.pyplot.show()

matplotlib.pyplot.figure(figsize=(25,2))#设置画布大小
matplotlib.pyplot.plot(keyword,value)#绘制折线图
matplotlib.pyplot.title("2024 年 7 月编程语言流行度树状图")#设置标题
matplotlib.pyplot.show()

运行结果

数据来源于GitHub

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值