pyecharts Visualization

pyecharts Visualization

  • Overview: Echarts is a visualization of Baidu open source data, with a good interactive, sophisticated graphic design, has been recognized by many developers. The Python is an expressive language, it is suitable for data processing. When the data analysis encounter data visualization, pyecharts born.
  • Features:
    simple API design, such as silky smooth, support for chained calls to
    include a 30+ kinds of common chart, everything
    supports mainstream Notebook environment, Jupyter Notebook and JupyterLab
    can be easily integrated into Flask, Django Web framework and other mainstream
    highly flexible configuration items, can easily match a beautiful chart
    detailed documentation and samples to help developers get started faster project
    up to 400+ maps, provide strong support for geographic data visualization

The use of the latest version of pyecharts (version 1.1.0 - 2019.5.14 (current )) somewhat different from the previous
1, data 1:

相机 574513370.0
短视频 460800929.0
视频 357233634.0
浏览器 237785883.0
商城 153678479.0
购票 104248080.0
小说 76975429.0
聊天 73931851.0
小工具 64636396.0
理财记账 55401117.0

It is acquired in pea pods data indicating the type of app downloads:
a bar graph expressed as:
Here Insert Picture Description
code as follows:

 bar = (

                    Bar()
                        .add_xaxis([ "总数"])
                        .set_global_opts(title_opts=opts.TitleOpts(title="APP类型", subtitle="APP类型"))
            )
 for item in items:
                print(item["_id"],item["sum_app"])
                bar.add_yaxis(item["_id"],[float(item["sum_app"])])
 bar.render("APP类型.html")

Represented by a pie chart:
Here Insert Picture Description
code is as follows:

 pie = (
                Pie()
                    .add(
                    "",
                    data_pair=[(i["_id"],i["sum_app"]) for i in items],    #数据为[(),()]
                    radius=["30%", "75%"],
                    center=["50%", "50%"],
                    rosetype="radius",
                    label_opts=opts.LabelOpts(is_show=False),
                )
                    .set_global_opts(title_opts=opts.TitleOpts(title="APP比例"))
                    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))

            )
  pie.render("pie_APP类型.html")           

Data 2:

{'_id': ObjectId('5cd7c7f106464a1a2e443ee5'), 'app_name': '快手', 'cate_name': '摄影图像', 'child_cate_name': '相机', 'comment': '记录生活中有趣的精彩瞬间', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/05/08/8/110_a5f8e78098dd93e4d0db4e094c505ff6_con_130x130.png', 'install': 560000000.0, 'volume': '70.95MB'}
{'_id': ObjectId('5cd7c69606464a1a2e4396fa'), 'app_name': '抖音短视频', 'cate_name': '影音播放', 'child_cate_name': '视频', 'comment': '音乐短视频软件,记录生活', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/05/08/0/110_54bd19d6bb330d544243f374ef5f82c7_con_130x130.png', 'install': 300000000.0, 'volume': '74.93MB'}
{'_id': ObjectId('5cd7c7e006464a1a2e443a25'), 'app_name': 'PP视频', 'cate_name': '摄影图像', 'child_cate_name': '短视频', 'comment': '因法之名中超独播', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/05/06/3/110_d401ffd3ce81e21f9aece04966830768_con_130x130.png', 'install': 300000000.0, 'volume': '84.45MB'}
{'_id': ObjectId('5cd7ca3e06464a1a2e44e845'), 'app_name': '搜狗浏览器', 'cate_name': '系统工具', 'child_cate_name': '浏览器', 'comment': '跨终端无缝体验,更快更流畅', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/05/06/4/2_4767f0eedb7a9007f55010e8cb0b49b4_con_130x130.png', 'install': 130000000.0, 'volume': '38.52MB'}
{'_id': ObjectId('5cd7c7e006464a1a2e443a5b'), 'app_name': '西瓜视频', 'cate_name': '摄影图像', 'child_cate_name': '短视频', 'comment': '懂得生活趣味的人都在用', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/04/30/11/110_df3642ec6802c165499293290faa17b8_con_130x130.png', 'install': 130000000.0, 'volume': '14.72MB'}
{'_id': ObjectId('5cd7c7cb06464a1a2e44332e'), 'app_name': '唯品会', 'cate_name': '网上购物', 'child_cate_name': '商城', 'comment': '全球精选正品特卖', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/04/30/5/110_1fa49397b975103927401c0b34fbd25d_con_130x130.png', 'install': 82081000.0, 'volume': '56.27MB'}
{'_id': ObjectId('5cd7c78d06464a1a2e441812'), 'app_name': '携程旅行', 'cate_name': '旅游出行', 'child_cate_name': '购票', 'comment': '动动指头,说走就走', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/05/06/8/110_e48d2872d0d87fc6bb8bd7ac1eca0295_con_130x130.png', 'install': 80511000.0, 'volume': '88.18MB'}
{'_id': ObjectId('5cd7ca3c06464a1a2e44e7ec'), 'app_name': 'UC浏览器', 'cate_name': '系统工具', 'child_cate_name': '浏览器', 'comment': '精彩资讯一刷即有', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/05/09/4/106_03e4f7bc555040ccbd7edae0e517d90c_con_130x130.png', 'install': 78939000.0, 'volume': '49.82MB'}
{'_id': ObjectId('5cd7c69906464a1a2e4398a5'), 'app_name': '中华万年历', 'cate_name': '生活休闲', 'child_cate_name': '小工具', 'comment': '查农历问风水,超过2亿中国人的选择', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/05/06/10/110_91f51359ce82762d5edcfeb02082c9f3_con_130x130.png', 'install': 51210000.0, 'volume': '14.46MB'}
{'_id': ObjectId('5cd7c7cb06464a1a2e44333e'), 'app_name': '手机淘宝', 'cate_name': '网上购物', 'child_cate_name': '商城', 'comment': '手机网购,一切商品全都有', 'icon_url': 'https://android-artworks.25pp.com/fs08/2019/04/30/11/110_76cc982ee58641bc0f9a06091c644633_con_130x130.png', 'install': 46664000.0, 'volume': '106.03MB'}

This is a pea pod download the app ranked in the top 10
bars represent:
Here Insert Picture Description
code is as follows:

 bar_sort = (

                Bar()
            .add_xaxis(['排名'])

                    .set_global_opts(title_opts=opts.TitleOpts(title="APP排名", subtitle="APP排名"))
            )
 for sort in sorts:
           bar_sort.add_yaxis(sort["app_name"],[sort["install"]])
 bar_sort.render("APP排名.html")

Word cloud:
Here Insert Picture Description

code show as below:

 words=[]
 for sort in sorts:
                words.append((sort["app_name"],sort["install"]))
yun = (
                WordCloud()
                    .add("", words, word_size_range=[20, 100], shape=SymbolType.DIAMOND)
                    .set_global_opts(title_opts=opts.TitleOpts(title="词云——APP排名"))
            )
 yun.render("词云——APP排名.html")

Guess you like

Origin blog.csdn.net/huangwencai123/article/details/90245004