• Pyecharts之平行坐标系(Parallel)


    Pyecharts之平行坐标系(Parallel)

    from snapshot_selenium import snapshot as driver
    
    from pyecharts import options as opts
    from pyecharts.charts import Parallel
    from pyecharts.render import make_snapshot
    
    from pyecharts.globals import CurrentConfig,NotebookType
    
    CurrentConfig.NOTEBOOK_TYPE=NotebookType.JUPYTER_LAB
    

    一.基本概念

    class pyecharts.charts.Parallel

    class Parallel(
        # 初始化配置项,参考 `global_options.InitOpts`
        init_opts: opts.InitOpts = opts.InitOpts()
    )
    

    func pyecharts.charts.Parallel.add_schema

    def add_schema(
        schema: Sequence[Union[opts.ParallelAxisOpts, dict]],
        parallel_opts: Union[opts.ParallelOpts, dict, None] = None,
    )
    

    func pyecharts.charts.Parallel.add

    def add(
        # 系列名称,用于 tooltip 的显示,legend 的图例筛选。
        series_name: str,
    
        # 系列数据
        data: Sequence,
    
        # 是否选中图例。
        is_selected: bool = True,
    
        # 是否平滑曲线
        is_smooth: bool = False,
    
        # 线条样式,参考 `series_options.LineStyleOpts`
        linestyle_opts: Union[opts.LineStyleOpts, dict] = opts.LineStyleOpts(),
    
        # 提示框组件配置项,参考 `series_options.TooltipOpts`
        tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
    
        # 图元样式配置项,参考 `series_options.ItemStyleOpts`
        itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
    )
    

    二.代码示例

    from pyecharts import options as opts
    from pyecharts.charts import Parallel
    
    parallel_axis=[
        {"dim":0,"name":"Price"},
        {"dim":1,"name":"Net Weight"},
        {"dim":2,"name":"Amount"},
        {
            "dim":3,
            "name":"Score",
            "type":"category",
            "data":["Excellent","Good","OK","Bad"]
        }
    ]
    
    data=[[12.99, 100, 82, "Good"], [9.99, 80, 77, "OK"], [20, 120, 60, "Excellent"]]
    
    p=(
        Parallel(init_opts=opts.InitOpts(width="1000px",height="600px"))
        .add_schema(schema=parallel_axis)
        .add(
            series_name="数据",
            data=data,
            linestyle_opts=opts.LineStyleOpts(width=4,opacity=0.5)
        )
        #.render("basic_parallel.html")
    )
    
    #make_snapshot(driver,g.render("gauge.html"),"gauge.png")
    
    p.load_javascript()
    p.render_notebook()
    
    from pyecharts import options as opts
    from pyecharts.charts import Parallel
    
    data = [
        [1, 91, 45, 125, 0.82, 34, 23, "良"],
        [2, 65, 27, 78, 0.86, 45, 29, "良"],
        [3, 83, 60, 84, 1.09, 73, 27, "良"],
        [4, 109, 81, 121, 1.28, 68, 51, "轻度污染"],
        [5, 106, 77, 114, 1.07, 55, 51, "轻度污染"],
        [6, 109, 81, 121, 1.28, 68, 51, "轻度污染"],
        [7, 106, 77, 114, 1.07, 55, 51, "轻度污染"],
        [8, 89, 65, 78, 0.86, 51, 26, "良"],
        [9, 53, 33, 47, 0.64, 50, 17, "良"],
        [10, 80, 55, 80, 1.01, 75, 24, "良"],
        [11, 117, 81, 124, 1.03, 45, 24, "轻度污染"],
        [12, 99, 71, 142, 1.1, 62, 42, "良"],
        [13, 95, 69, 130, 1.28, 74, 50, "良"],
        [14, 116, 87, 131, 1.47, 84, 40, "轻度污染"],
    ]
    p = (
        Parallel()
        .add_schema(
            [
                opts.ParallelAxisOpts(dim=0, name="data"),
                opts.ParallelAxisOpts(dim=1, name="AQI"),
                opts.ParallelAxisOpts(dim=2, name="PM2.5"),
                opts.ParallelAxisOpts(dim=3, name="PM10"),
                opts.ParallelAxisOpts(dim=4, name="CO"),
                opts.ParallelAxisOpts(dim=5, name="NO2"),
                opts.ParallelAxisOpts(dim=6, name="CO2"),
                opts.ParallelAxisOpts(
                    dim=7,
                    name="等级",
                    type_="category",
                    data=["优", "良", "轻度污染", "中度污染", "重度污染", "严重污染"],
                ),
            ]
        )
        .add("介质", data)
        .set_global_opts(title_opts=opts.TitleOpts(title="Parallel-Category"))
        #.render("parallel_category.html")
    )
    
    #make_snapshot(driver,g.render("gauge.html"),"gauge.png")
    
    p.load_javascript()
    p.render_notebook()
    
    
    
  • 相关阅读:
    阶段1 语言基础+高级_1-2 -面向对象和封装_2面向对象思想的举例
    阶段1 语言基础+高级_1-2 -面向对象和封装_1面向对象思想的概述
    2-3 【初识组件】顶部 TabBar
    2-2 工程源码文件结构
    Fragment状态保存
    【51单片机】六种亮灯方式
    Hadoop自学笔记(二)HDFS简单介绍
    lvs 负载均衡环境搭建
    [学习笔记—Objective-C]《Objective-C-基础教程 第2版》第十一章 属性
    说说nio----1
  • 原文地址:https://www.cnblogs.com/LQ6H/p/12940531.html
Copyright © 2020-2023  润新知