signed

QiShunwang

“诚信为本、客户至上”

17 基于pyecharts的python数据可视化——实际应用案例(分析各类APP下载量)

2021/6/3 13:05:51   来源:

目录

1、绘制各类APP下载量的柱状图

2、绘制各类APP下载量的饼图

3、绘制各类APP下载量的涟漪特效散点图

4、绘制各类APP下载量的折线图


      前面7篇博客分别介绍了使用pyecharts库来绘制柱状图、饼图、K线图、散点图、仪表盘图、玫瑰图、漏斗图以及组合图表的绘制方法。那么,通过前面几篇的学习,来进行一个总结和提升。本篇内容针对一些APP的下载数据来利用pyecharts进行可视化分析。

APP下载数据展示

# 数据设置
items = ["相机","短视频","视频","浏览器","购物","购票","小说","聊天","小工具","理财金融"]
data = [[5041357],[43055789],[50456489],[25467820],[60454689],[16043589],[35312478],[65468912],[16075789],[30905289]]

1、绘制各类APP下载量的柱状图

from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.options.global_options import ThemeType

# 数据设置
items = ["相机","短视频","视频","浏览器","购物","购票","小说","聊天","小工具","理财金融"]
data = [[5041357],[43055789],[50456489],[25467820],[60454689],[16043589],[35312478],[65468912],[16075789],[30905289]]

# bar = Bar(init_opts=opts.InitOpts(theme = ThemeType.LIGHT))   # 图表主题设置
bar = Bar()    # 绘制条形图
bar.add_xaxis(["APP类别"])
for item in items:
    bar.add_yaxis(item,data[items.index(item)])# Y轴数据设置
    
# 全局参数设置
bar.set_global_opts(title_opts=opts.TitleOpts(title = "APP下载",subtitle="下载数量"))

bar.render("APP下载数据分析.html")
# bar.render_notebook()

2、绘制各类APP下载量的饼图

# 相关库导入
from pyecharts.charts import Pie
from pyecharts import options as opts
from pyecharts.options.global_options import ThemeType

# 数据设置
items = ["相机", "短视频", "视频", "浏览器", "购物", "购票", "小说", "聊天", "小工具", "理财金融"]
data = [[5041357], [43055789], [50456489], [25467820], [60454689], [16043589], [35312478], [65468912], [16075789],
        [30905289]]

# 饼图绘制
pie = Pie(init_opts=opts.InitOpts(theme = ThemeType.LIGHT))   # 图表主题设置
pie.add("",data_pair=[(item,data[items.index(item)])for item in items],
        radius=["30%","75%"],
        center=["50%","50%"],
        rosetype="radius",
        label_opts=opts.LabelOpts(is_show = False))

# 全局和局部参数设置
pie.set_global_opts(title_opts=opts.TitleOpts(title="APP下载\n数量占比"))
pie.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}:{c}"))

pie.render("APP下载数据分析.html")
# pie.render_notebook()

3、绘制各类APP下载量的涟漪特效散点图

from pyecharts.charts import EffectScatter
from pyecharts import options as opts

# 数据设置
items = ["相机", "短视频", "视频", "浏览器", "购物", "购票", "小说", "聊天", "小工具", "理财金融"]     # X轴数据
data = [[5041357], [43055789], [50456489], [25467820], [60454689], [16043589], [35312478], [65468912], [16075789],
        [30905289]]     # Y轴数据

c = EffectScatter()
# 实例化对象
c.add_xaxis(items)
c.add_yaxis("",data,color=False)
c.set_global_opts(title_opts=opts.TitleOpts(title="APP下载数量"))
# c.render()
c.render_notebook()

4、绘制各类APP下载量的折线图

from pyecharts.charts import Line
from pyecharts import options as opts

# 数据设置
items = ["相机", "短视频", "视频", "浏览器", "购物", "购票", "小说", "聊天", "小工具", "理财金融"]
data = [[5041357], [43055789], [50456489], [25467820], [60454689], [16043589], [35312478], [65468912], [16075789],
        [30905289]]

c = Line()
# 实例化对象
c.add_xaxis(items)
c.add_yaxis("",data,color=False)
c.set_global_opts(title_opts=opts.TitleOpts(title="APP下载数量"))
# c.render()
c.render_notebook()