学习笔记:python数据分析:6.Python + PyEcharts——数据可视化(下)

饼图Pie

from pyecharts.charts import Pie    # 导入pyecharts图表模块的饼图
from pyecharts.faker import Faker   # 导入pyecharts随机虚构数据模块
from pyecharts import options as opts  # 导入图表配置模块

pie = Pie()
pie.add("", [list(z) for z in zip(Faker.choose(), Faker.values())])
pie.set_global_opts(title_opts=opts.TitleOpts(title="Pie-基本示例"))
pie.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
pie.render("pie_base.html")

创建一个圆环饼图

from pyecharts.charts import Pie    # 导入pyecharts图表模块的饼图
from pyecharts.faker import Faker   # 导入pyecharts随机虚构数据模块
from pyecharts import options as opts  # 导入图表配置模块

pie = Pie()
pie.add("", [list(z) for z in zip(Faker.choose(), Faker.values())],radius=["40%","75%"])
pie.set_global_opts(title_opts=opts.TitleOpts(title="Pie-基本示例"))
pie.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
pie.render("pie_base.html")

radius: 内环和外环半径,列表类型

创建一个玫瑰饼图

from pyecharts.charts import Pie    # 导入pyecharts图表模块的饼图
from pyecharts.faker import Faker   # 导入pyecharts随机虚构数据模块
from pyecharts import options as opts  # 导入图表配置模块

pie = Pie()
pie.add("", [list(z) for z in zip(Faker.choose(), Faker.values())],radius=["40%","75%"],rosetype="area")
pie.set_global_opts(title_opts=opts.TitleOpts(title="Pie-基本示例"))
pie.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
pie.render("pie_base.html")

rosetype: 设置玫瑰饼图的模式
radius:扇区圆心角展现数据的百分比,半径展现数据的大小
area:所有扇区圆心角相同,仅通过半径展现数据大小

EffectScatter(带有涟漪特效动画的散点图)

from pyecharts import options as opts
from pyecharts.charts import EffectScatter
from pyecharts.faker import Faker
from pyecharts.globals import SymbolType

effect_scatter = EffectScatter()
effect_scatter.add_xaxis(Faker.choose())
effect_scatter.add_yaxis("", Faker.values(), symbol=SymbolType.ARROW)
effect_scatter.set_global_opts(title_opts=opts.TitleOpts(title="EffectScatter-不同Symbol"))
effect_scatter.render("effectscatter_symbol.html")

漏斗图

from pyecharts import options as opts
from pyecharts.charts import Funnel
from pyecharts.faker import Faker

funnel = Funnel()
funnel.add(
    "商品",
    [list(z) for z in zip(Faker.choose(), Faker.values())],
    label_opts=opts.LabelOpts(position="inside"))
funnel.set_global_opts(title_opts=opts.TitleOpts(title="Funnel"))
funnel.render()

Geo(地理坐标系)

from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.faker import Faker

geo = Geo()
geo.add_schema(maptype="china")
geo.add("geo", [list(z) for z in zip(Faker.provinces, Faker.values())])
geo.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
geo.set_global_opts(
    visualmap_opts=opts.VisualMapOpts(), title_opts=opts.TitleOpts(title="Geo-基本示例"),
    )
geo.render("geo_base.html")

Liquid(水球图)

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

liquid = Liquid()
liquid.add("Liquid", [0.6, 0.7])
liquid.set_global_opts(title_opts=opts.TitleOpts(title="Liquid-基本示例"))
liquid.render()

is_outline_show: 是否显示外边框
is_animation: 是否显示动画效果
shape: 边框形状,和symbol可用的
形状类似,还可以自定义

雷达图

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

v1 = [[4300, 10000, 28000, 35000, 50000, 19000]]
v2 = [[5000, 14000, 28000, 31000, 42000, 21000]]

radar = Radar()
radar.add_schema(
    schema=[
        opts.RadarIndicatorItem(name="销售", max_=6500),
        opts.RadarIndicatorItem(name="管理", max_=16000),
        opts.RadarIndicatorItem(name="信息技术", max_=30000),
        opts.RadarIndicatorItem(name="客服", max_=38000),
        opts.RadarIndicatorItem(name="研发", max_=52000),
        opts.RadarIndicatorItem(name="市场", max_=25000),
    ]
)
radar.add("预算分配", v1)
radar.add("实际开销", v2)
radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
radar.set_global_opts(
    legend_opts=opts.LegendOpts(selected_mode="single"),
    title_opts=opts.TitleOpts(title="Radar-单例模式"),
)
radar.render()

WordCloud(词云图)

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

words = [
    ("花鸟市场", 1446),
    ("汽车", 928),
    ("视频", 906),
    ("电视", 825),
    ("Lover Boy 88", 514),
    ("动漫", 486),
    ("音乐", 53),
    ("直播", 163),
    ]

wordcloud = WordCloud()
wordcloud.add("", words, word_size_range=[5, 55])
wordcloud.set_global_opts(title_opts=opts.TitleOpts(title="WordCloud"))
wordcloud.render()

可爱风格

pip install cutecharts
https://github.com/chenjiandongx/cutecharts
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 1024 设计师: 上身试试
应支付0元
点击重新获取
扫码支付

支付成功即可阅读