Python画图神器之--pyecharts


嗯,直接上代码再说明!|ू・ω・` )

# 导入相关包
import pandas as pd
from pyecharts.charts import *
from pyecharts import options as opts
from pyecharts.globals import *
from pyecharts.faker import *
# 读取数据
data=pd.read_csv('D:/机器学习/air_quality.csv',sep=',')
fun1=lambda x:x.split('-')[0]
fun2=lambda x:x.split('-')[1]
data['year']=data['record_date'].apply(fun1)
data['month']=data['record_date'].apply(fun2)

https://img-blog.csdnimg.cn/20191228141537669.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTM0MjE2Mjk=,size_16,color_FFFFFF,t_70https://img-blog.csdnimg.cn/20191228141537669.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTM0MjE2Mjk=,size_16,color_FFFFFF,t_70

# 成都空气质量的玫瑰花饼图
df1=data.groupby(['city_name','quality_level'], as_index=False).count()
df1=df1[df1['city_name']=='成都']
x = list(df1['quality_level'])
y = list(df1['so2_val'])

pie = Pie(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
pie.add("",[list(z) for z in zip(x, y)],radius=["50%", "75%"],center=["45%", "60%"],rosetype="radius",)
# pie.set_colors(["blue", "green", "yellow", "red", "pink", "orange"])
pie.set_series_opts(label_opts=opts.LabelOpts(is_show=True))
pie.set_global_opts(title_opts=opts.TitleOpts(title="成都空气质量玫瑰花饼图",pos_left="32%"),
                    legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="5%"))
pie.render_notebook()
# pie.render(data_path+'成都空气质量饼图.html')

https://img-blog.csdnimg.cn/20191228141712934.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTM0MjE2Mjk=,size_16,color_FFFFFF,t_70https://img-blog.csdnimg.cn/20191228141712934.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTM0MjE2Mjk=,size_16,color_FFFFFF,t_70

pyecharts官方文档

挺好看的吧!Fight!!(o-)尸~’'☆ミ☆ミ


文章作者: 远方客
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 远方客 !
评论
 上一篇
云服务器初识 云服务器初识
文章目的:通过学生成长计划领取资格考试 - 云计算及云服务器入门的考试,获得12个月的云服务器。 云服务器(ECS) 1.搭建个人网站 已经做了很多了,就不多讲了!用宝塔+wordress document.querySe
2020-02-08
下一篇 
三大深度学习框架的简单了解 三大深度学习框架的简单了解
简要记录一下我感兴趣且也比较流行的三大深度学习框架,分别是:Pytroch,tensorflow,paddle(百度飞桨)。 Pytorch 官方:PyTorch是是torch的python版本,是由Facebook开源的神经网络框架,专门
2020-02-06
  目录