예제 #1
0
def parallel_category() -> 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, "轻度污染"],
    ]
    c = (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("parallel", data).set_global_opts(title_opts=opts.TitleOpts(
        title="Parallel-Category")))
    return c
예제 #2
0
    def _echarts_axis_opts(self):
        """
        构建坐标系,按照值是string类或数字类,构建相应的坐标系
        Returns:

        """
        res = []
        for i, (k, v) in enumerate(self.tag_dict.items()):
            if isinstance(v[0], str):
                vv = list(set(v))
                vv.sort()
                res.append(opts.ParallelAxisOpts(dim=i, name=k, type_="category", data=vv))
            else:
                res.append(opts.ParallelAxisOpts(dim=i, name=k, max_=max(v), min_=min(v)))

        return res
예제 #3
0
    def _echarts_axis_opts(self):
        """
        ([{'epoch': 3,
   'eidx': 1,
   'idx': 0,
   'global_step': 0,
   'device': 'cpu',
   'optim.lr': 0.1},
  {'epoch': 3,
   'eidx': 1,
   'idx': 0,
   'global_step': 0,
   'device': 'cpu',
   'optim.lr': 0.001}],
 [{'auto_train_loss': 3.7000625133514404},
  {'auto_train_loss': 2.3023736476898193}])
        :return:
        """
        str_opts = defaultdict(list)
        for i, (k, v) in enumerate(
                chain(self.params_dicts[0].items(),
                      self.metric_dicts[0].items())):
            if isinstance(v, str):
                str_opts[k].append(v)

        res = []
        for i, (k, _) in enumerate(
                chain(self.params_dicts[0].items(),
                      self.metric_dicts[0].items())):
            if k in str_opts:
                res.append(
                    opts.ParallelAxisOpts(dim=i,
                                          name=k,
                                          type_="category",
                                          data=str_opts[k]))
            else:
                res.append(opts.ParallelAxisOpts(dim=i, name=k))

        return res
예제 #4
0
    [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, "轻度污染"],
]

c = (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(
    "parallel",
    data,
예제 #5
0
import datetime
import math
import pyecharts.options as opts
import random
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts.faker import POPULATION
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
# %%
# 直角坐标系图表
# 直方图
x_data = ['apple', 'huawei', 'xiaomi', 'oppo', 'vivo', 'meizu']
y_data = [123, 312, 89, 107, 82, 23]
bar = (Bar().add_xaxis(x_data).add_yaxis('', y_data))
bar.render()
# %%
# 折线图
x_data = ['apple', 'huawei', 'xiaomi', 'oppo', 'vivo', 'meizu']
y_data = [123, 312, 89, 107, 82, 23]
bar = (Line().add_xaxis(x_data).add_yaxis('', y_data))
bar.render()
# %%
# 折线图
x_data = ['apple', 'huawei', 'xiaomi', 'oppo', 'vivo', 'meizu']
y_data = [[random.randint(100, 200) for i in range(10)] for item in x_data]
Box = Boxplot()
Box.add_xaxis(x_data)
Box.add_yaxis('', Box.prepare_data(y_data))
bar.render()