Ejemplo n.º 1
0
def surface3D_flower() -> Surface3D:
    def surface3d_data():
        for t0 in range(-30, 30, 1):
            y = t0 / 10
            for t1 in range(-30, 30, 1):
                x = t1 / 10
                z = math.sin(x * x + y * y) * x / 3.14
                yield [x, y, z]

    c = (
        Surface3D()
        .add(
            "",
            list(surface3d_data()),
            xaxis3d_opts=opts.Axis3DOpts(type_="value"),
            yaxis3d_opts=opts.Axis3DOpts(type_="value"),
            grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
        )
        .set_global_opts(
            title_opts=opts.TitleOpts(title="Surface3D-曲面波图"),
            visualmap_opts=opts.VisualMapOpts(
                max_=1, min_=-1, range_color=Faker.visual_color
            ),
        )
    )
    return c
Ejemplo n.º 2
0
def creat_pivot_chart(pivot, index, column, agg, value):
    index_list = pivot.index.tolist()
    column_list = pivot.columns.tolist()
    if pivot.max().tolist():
        visualmap_max = max(pivot.max().tolist())
        range_text = ['最大值', '最小值']
    else:
        visualmap_max = 1
        range_text = ['无', '数据']
    # print(pivot.max())
    data = [(i, j, int(pivot.iloc[i, j])) for i in range(len(index_list))
            for j in range(len(column_list))]
    c = (Bar3D().add(
        series_name=agg + '(' + value + ')',
        data=data,
        shading="lambert",
        xaxis3d_opts=opts.Axis3DOpts(index_list, type_="category", name=index),
        yaxis3d_opts=opts.Axis3DOpts(column_list,
                                     type_="category",
                                     name=column),
        zaxis3d_opts=opts.Axis3DOpts(type_="value",
                                     name=agg + '(' + value + ')'),
    ).set_global_opts(visualmap_opts=opts.VisualMapOpts(max_=visualmap_max,
                                                        range_text=range_text),
                      title_opts=opts.TitleOpts(title="数据透视三维图"),
                      toolbox_opts=opts.ToolboxOpts(),
                      datazoom_opts=opts.DataZoomOpts(type_="inside")))
    return c
Ejemplo n.º 3
0
def line3d_base():
    data = []
    for t in range(0, 25000):
        _t = t / 1000
        x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
        y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
        z = _t + 2.0 * math.sin(75 * _t)
        data.append([x, y, z])
    c = (Line3D().add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100,
                                    height=100,
                                    depth=100,
                                    rotate_speed=150,
                                    is_rotate=True),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=30,
                                          min_=0,
                                          range_color=Faker.visual_color),
        title_opts=opts.TitleOpts(title="Line3D-旋转的弹簧"),
    ))
    return c
    def draw_bar3D(cls, title: str, data: pd.DataFrame) -> Bar3D:
        """
        根据df内容绘制3D柱状图
        :param title:           标题
        :param data:            包含三轴数据的dataframe  index为x轴 column为Y轴 value为z轴
        :return:
        """
        data_list = []
        index_list = data.index.tolist()
        column_list = data.columns.tolist()

        # 获取dataframe最大最小值
        min_data = data.min().min()
        max_data = data.max().max()
        # 遍历dataframe,准备待操作数组
        for i in range(len(index_list)):
            for j in range(len(column_list)):
                # 记录 XYZ
                temp_list = [index_list[i], column_list[j], data.iloc[i, j]]
                # print(i,j,index_list[i],column_list[j])
                data_list.append(temp_list)

        c = (
            Bar3D(init_opts=opts.InitOpts(
                width=DEFAULT_WIDTH,
                animation_opts=opts.AnimationOpts(
                    animation_delay=200,
                    animation_easing="bounceOut"),  #   增加启动动效
            )).add(
                series_name=title,
                data=data_list,
                xaxis3d_opts=opts.Axis3DOpts(type_="category",
                                             data=index_list),
                yaxis3d_opts=opts.Axis3DOpts(type_="category",
                                             data=column_list),
                zaxis3d_opts=opts.Axis3DOpts(type_="value"),
            ).set_series_opts(label_opts=opts.LabelOpts(is_show=True)).
            set_global_opts(
                title_opts=opts.TitleOpts(title=title, pos_left="0%"),
                toolbox_opts=opts.ToolboxOpts(),  # 显示工具箱
                tooltip_opts=opts.TooltipOpts(is_show=True),
                axispointer_opts=opts.AxisPointerOpts(
                    is_show=True, type_="none"),  # 指针移动时显示所有数值
                legend_opts=opts.LegendOpts(
                    is_show=True,
                    selected_mode="multiple",
                    # pos_bottom="0%",
                    # pos_right="0%",
                    # orient="vertical",
                ),  # 显示图例说明
                # datazoom_opts=[
                #     opts.DataZoomOpts(
                #         range_start=0, range_end=100, orient="vertical", pos_left="2%"
                #     ),
                #     opts.DataZoomOpts(range_start=0, range_end=100, orient="horizontal"),
                # ],  # 增加缩放配置横纵轴都支持缩放
                visualmap_opts=opts.VisualMapOpts(max_=max_data, min_=min_data)
                # visualmap_opts=opts.VisualMapOpts(type_="color", max_=1, min_=-1),
            ))
        return c
Ejemplo n.º 5
0
def bar3d_base() -> Bar3D:
    data = read_do()
    data_tip = [
        "使用总能耗 [kW]", "发电 [kW]", "洗碗机 [kW]", "炉子 1 [kW]", "房屋整体能耗 [kW]",
        "冰箱 [kW]", "酒窖 [kW]", "车库门 [kW]"
    ]
    data_year = [
        2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
        2018, 2019
    ]

    c = (Bar3D().add("",
                     data,
                     xaxis3d_opts=opts.Axis3DOpts(data_tip,
                                                  type_="category",
                                                  max_=8),
                     yaxis3d_opts=opts.Axis3DOpts(data_year, max_=2020),
                     zaxis3d_opts=opts.Axis3DOpts(type_="value", max_=1),
                     grid3d_opts=opts.Grid3DOpts(
                         width="180", height="50")).set_global_opts(
                             visualmap_opts=opts.VisualMapOpts(max_=1),
                             title_opts=opts.TitleOpts(title="部分能耗图"),
                         ))

    return c
Ejemplo n.º 6
0
 def bar_base() -> Scatter3D:
     c = (
         Scatter3D(init_opts=opts.InitOpts(
             width="1440px", height="720px"))  # bg_color="black"
         .add(
             series_name="",
             data=data,
             xaxis3d_opts=opts.Axis3DOpts(
                 name=config_xAxis3D,
                 type_="value",
                 # textstyle_opts=opts.TextStyleOpts(color="#fff"),
             ),
             yaxis3d_opts=opts.Axis3DOpts(
                 name=config_yAxis3D,
                 type_="value",
                 # textstyle_opts=opts.TextStyleOpts(color="#fff"),
             ),
             zaxis3d_opts=opts.Axis3DOpts(
                 name=config_zAxis3D,
                 type_="value",
                 # textstyle_opts=opts.TextStyleOpts(color="#fff"),
             ),
             grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
         )
         # .render("scatter3d.html")
     )
     return c
Ejemplo n.º 7
0
def surface3d_base() -> Surface3D:
    def surface3d_data():
        for t0 in range(-60, 60, 1):
            y = t0 / 60
            for t1 in range(-60, 60, 1):
                x = t1 / 60
                if math.fabs(x) < 0.1 and math.fabs(y) < 0.1:
                    z = "-"
                else:
                    z = math.sin(x * math.pi) * math.sin(y * math.pi)
                yield [x, y, z]

    c = (Surface3D().add(
        "",
        list(surface3d_data()),
        xaxis3d_opts=opts.Axis3DOpts(type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
    ).set_global_opts(
        title_opts=opts.TitleOpts(title="Surface3D-基本示例"),
        visualmap_opts=opts.VisualMapOpts(max_=3,
                                          min_=-3,
                                          range_color=Faker.visual_color),
    ))
    return c
Ejemplo n.º 8
0
def bar3d():
    data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(12)]
    c = (Bar3D().add(
        '', [[d[1], d[0], d[2]] for d in data],
        xaxis3d_opts=op.Axis3DOpts(Faker.color, type_='category'),
        yaxis3d_opts=op.Axis3DOpts(Faker.week_en, type_='category'),
        zaxis3d_opts=op.Axis3DOpts(type_='value')).set_global_opts(
            visualmap_opts=op.VisualMapOpts(max_=20),
            title_opts={'text': '三维'}))
    return c
Ejemplo n.º 9
0
def bar3d_html(data):
    raw = pd.read_csv(data, header=0, index_col=0, sep=None, engine='python')
    data = [(i, j, raw.loc[j, i]) for i in raw.columns for j in raw.index]
    c = (Bar3D().add(
        "",
        [[d[1], d[0], d[2]] for d in data],
        xaxis3d_opts=opts.Axis3DOpts(raw.index, type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(raw.columns, type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).set_global_opts(visualmap_opts=opts.VisualMapOpts(max_=20), ))
    c.render('bar3d.html')
Ejemplo n.º 10
0
def test_bar3d_base():
    data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]
    c = (Bar3D().add(
        "",
        [[d[1], d[0], d[2]] for d in data],
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).set_global_opts(visualmap_opts=opts.VisualMapOpts(max_=20)))
    eq_(c.theme, "white")
    eq_(c.renderer, "canvas")
    c.render()
Ejemplo n.º 11
0
def bar3d_base() -> Bar3D:
    data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]
    c = (Bar3D().add(
        "",
        [[d[1], d[0], d[2]] for d in data],
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=20),
        title_opts=opts.TitleOpts(title="Bar3D-基本示例"),
    ))
    return c
Ejemplo n.º 12
0
def bar3d_base() -> Bar3D:
    data = [(i, j, int(results[i][j])) for i in range(11) for j in range(11)]

    c = (Bar3D().add(
        "",
        [[d[1], d[0], d[2]] for d in data],
        xaxis3d_opts=opts.Axis3DOpts(xlist, type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(ylist, type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=1100),
        title_opts=opts.TitleOpts(title="Bar3D-Boston crash accident account"),
    ))
    return c
Ejemplo n.º 13
0
 def bar3d_base() -> Bar3D:
     data = [(i, j, random.randint(0, 1)) for i in range(6)
             for j in range(24)]
     c = (Bar3D().add(
         "",
         [[d[1], d[0], d[2]] for d in data],
         xaxis3d_opts=opts.Axis3DOpts(city_nms_top10, type_="category"),
         yaxis3d_opts=opts.Axis3DOpts(city_nums_top10, type_="category"),
         zaxis3d_opts=opts.Axis3DOpts(type_="value"),
     ).set_global_opts(
         visualmap_opts=opts.VisualMapOpts(max_=20),
         title_opts=opts.TitleOpts(title="Bar3D-Python工程师"),
     ))
     return c
Ejemplo n.º 14
0
def bar3d_stack():
    x_data = y_data = list(range(10))
    bar3d = Bar3D()
    for _ in range(10):
        bar3d.add(
            "",
            generate_date(),
            shading="lambert",
            xaxis3d_opts=opts.Axis3DOpts(data=x_data, type_="value"),
            yaxis3d_opts=opts.Axis3DOpts(data=y_data, type_="value"),
            zaxis3d_opts=opts.Axis3DOpts(type_="value"),
        )
    bar3d.set_global_opts(title_opts=opts.TitleOpts("Bar3D-堆叠柱状图示例"))
    bar3d.set_series_opts(**{"stack": "stack"})
    return bar3d
Ejemplo n.º 15
0
 def init_bar3d_base(self):
     from example.commons import Faker
     from pyecharts import options as opts
     from pyecharts.charts import Bar3D
     c = (Bar3D().add(
         "",
         [],
         xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
         yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),
         zaxis3d_opts=opts.Axis3DOpts(type_="value"),
     ).set_global_opts(
         visualmap_opts=opts.VisualMapOpts(max_=20),
         title_opts=opts.TitleOpts(title=""),
     ))
     return c
Ejemplo n.º 16
0
def draw():
    areas = [
        '0-50', '50-100', '100-150', '150-200', '200-250', '250-300',
        '300-350', '350+'
    ]
    dic = {}

    with open("清洗后城市二手房数据.csv", 'r', encoding='utf8') as f:
        reader = csv.reader(f)
        data = list(reader)
        Bar3D().add(
            series_name="",
            data=[[item[0], item[4], item[6]] for item in data],
            xaxis3d_opts=opts.Axis3DOpts(name='城市', type_='category'),
            yaxis3d_opts=opts.Axis3DOpts(name='总价'),
            zaxis3d_opts=opts.Axis3DOpts(name='面积')).render("bar3D.html")
Ejemplo n.º 17
0
def article_day_3d():
    today = datetime.datetime.strptime('2019-12-31', '%Y-%m-%d')
    date_list = [[(today - datetime.timedelta(days=i)).strftime('%Y-%m-%d'),
                  (today - datetime.timedelta(days=i)).isocalendar()[1],
                  (today - datetime.timedelta(days=i)).isocalendar()[2]]
                 for i in range(365)]
    date_list.reverse()

    data = [[
        date[1], date[2],
        WechatArticle.query.filter(
            and_(
                extract('year', WechatArticle.publish_time) == str(
                    date[0]).split('-')[0],
                extract('month', WechatArticle.publish_time) == str(
                    date[0]).split('-')[1],
                extract('day', WechatArticle.publish_time) == str(
                    date[0]).split('-')[2],
            )).count()
    ] for date in date_list]
    c = (Bar3D().add(
        "",
        [[d[0], d[1] - 1, d[2]] for d in data],
        xaxis3d_opts=opts.Axis3DOpts(data=[i for i in range(1, 53)],
                                     type_="category",
                                     name='一年周期',
                                     name_gap=30),
        yaxis3d_opts=opts.Axis3DOpts(data=Faker.week_en,
                                     type_="category",
                                     name='week'),
        zaxis3d_opts=opts.Axis3DOpts(type_="value", name='每天数量'),
        grid3d_opts=opts.Grid3DOpts(width=300,
                                    height=120,
                                    depth=120,
                                    rotate_speed=10,
                                    is_rotate=True),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=210,
                                          range_color=Faker.visual_color),
        title_opts=opts.TitleOpts(title="2019公众号文章发布统计",
                                  pos_top='10%',
                                  pos_left='43%'),
        legend_opts=opts.LegendOpts(item_gap=20, item_width=20),
    ))
    c.render(path='./static/year/article_day_3d.html')
    print('生成3D文章发布统计')
    return c
Ejemplo n.º 18
0
def plot_asset_distribution():
    months = [
        "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月",
        "12月"
    ]
    years = [str(x.year) for x in YearDB.objects.all()]
    years = years[::-1]
    data = []
    for idx1, month in enumerate(months):
        for idx2, year in enumerate(years):
            data.append([idx1, idx2, 0])
    for each in IncomDB.objects.all():
        each_year = each.Year.year
        each_month = each.monthly
        if each_year in years and each_month in months:
            idx = years.index(
                each_year) + months.index(each_month) * len(years)
            data[idx] = [
                months.index(each_month),
                years.index(each_year),
                float(each.actual_balance)
            ]

    bar_3d = (Bar3D(
        init_opts=opts.InitOpts(width="1400px", height="700px")).add(
            series_name="存款",
            data=data,
            xaxis3d_opts=opts.Axis3DOpts(type_="category", data=months),
            yaxis3d_opts=opts.Axis3DOpts(type_="category", data=years),
            zaxis3d_opts=opts.Axis3DOpts(type_="value"),
        ).set_global_opts(visualmap_opts=opts.VisualMapOpts(max_=100000,
                                                            range_color=[
                                                                "#313695",
                                                                "#4575b4",
                                                                "#74add1",
                                                                "#abd9e9",
                                                                "#e0f3f8",
                                                                "#ffffbf",
                                                                "#fee090",
                                                                "#fdae61",
                                                                "#f46d43",
                                                                "#d73027",
                                                                "#a50026",
                                                            ])))
    abs = os.path.dirname(__file__)
    bar_3d.render(abs + "/static/analysis.html")
Ejemplo n.º 19
0
def bar3d_base() -> Bar3D:
    import random
    from example.commons import Faker
    from pyecharts import options as opts
    from pyecharts.charts import Bar3D
    data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]
    c = (Bar3D().add(
        "",
        [[d[1], d[0], d[2]] for d in data],
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=20),
        title_opts=opts.TitleOpts(title=""),
    ))
    return c
Ejemplo n.º 20
0
def bar3d_base() -> Bar3D:
    # data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]
    # print([[d[1], d[0], d[2]] for d in data])
    c = (
        Bar3D(init_opts=opts.InitOpts(width='1200px', height='1000px'))
        .add(
            "",
            data,
            xaxis3d_opts=opts.Axis3DOpts(date1, type_="category"),
            yaxis3d_opts=opts.Axis3DOpts(start_uids, type_="category"),
            zaxis3d_opts=opts.Axis3DOpts(type_="value"),
        )
        .set_global_opts(
            visualmap_opts=opts.VisualMapOpts(max_=500),
            title_opts=opts.TitleOpts(title="情感分析3D"),
        )
    )
    return c
def gzu_major_satisfied():
    data1 = analysis_data.gzu_satisfied()
    data1 = data1.iloc[:, :5]
    data = [(i, j, data1.iloc[i, j + 1]) for i in range(data1.shape[0])
            for j in range(data1.shape[1] - 1)]
    c = (Bar3D().add(
        "",
        [[d[0], d[1], d[2]] for d in data],
        xaxis3d_opts=opts.Axis3DOpts([x[0] for x in data1.values],
                                     type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(['综合满意度', '办学条件满意度', '教学质量满意度', '就业满意度'],
                                     type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(min_=0, max_=2),
        title_opts=opts.TitleOpts(title="贵州大学专业满意度"),
    ))
    return c
Ejemplo n.º 22
0
def echart_plot_3d(data):
    from pyecharts.charts import Bar3D
    from pyecharts import options as opts

    print(data.tail())

    df = data[['s_Time', '未来=月终收益', '预测值']].values.tolist()

    (Bar3D(init_opts=opts.InitOpts(width="1600px", height="800px")).add(
        "",
        df,
        xaxis3d_opts=opts.Axis3DOpts(type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(type_="value"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=100000),
        title_opts=opts.TitleOpts(title="predict"),
    ).render("predict.html"))
Ejemplo n.º 23
0
    def draw_bar3D(self):
        from pyecharts.faker import Faker
        from pyecharts import options as opts

        data = [(i, j, random.randint(0, 12)) for i in range(6)
                for j in range(24)]
        c = (Bar3D(init_opts=opt.InitOpts(js_host="js2/")).add(
            "",
            [[d[1], d[0], d[2]] for d in data],
            xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
            yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),
            zaxis3d_opts=opts.Axis3DOpts(type_="value"),
        ).set_global_opts(
            visualmap_opts=opts.VisualMapOpts(max_=20),
            title_opts=opts.TitleOpts(title="Bar3D-基本示例"),
        ).render('bar3d1.html'))
        print(c)
        return c
Ejemplo n.º 24
0
def test_line3d_base():
    data = []
    for t in range(0, 25000):
        _t = t / 1000
        x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
        y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
        z = _t + 2.0 * math.sin(75 * _t)
        data.append([x, y, z])
    c = (Line3D().add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
    ).set_global_opts(visualmap_opts=opts.VisualMapOpts(
        max_=30, min_=0, range_color=Faker.visual_color)))
    eq_(c.theme, "white")
    eq_(c.renderer, "canvas")
    c.render()
Ejemplo n.º 25
0
def line3d():
    week_en = "Saturday Friday Thursday Wednesday Tuesday Monday Sunday".split(
    )
    clock = ("12a 1a 2a 3a 4a 5a 6a 7a 8a 9a 10a 11a 12p "
             "1p 2p 3p 4p 5p 6p 7p 8p 9p 10p 11p".split())
    _data = []
    for t in range(0, 25000):
        _t = t / 1000
        x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
        y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
        z = _t + 2.0 * math.sin(75 * _t)
        _data.append([x, y, z])
    range_color = [
        '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
        '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'
    ]
    line3d = Line3D()
    line3d.set_global_opts(visualmap_opts=opts.VisualMapOpts(
        dimension=2,
        max_=30,
        min_=0,
        range_color=[
            "#313695",
            "#4575b4",
            "#74add1",
            "#abd9e9",
            "#e0f3f8",
            "#ffffbf",
            "#fee090",
            "#fdae61",
            "#f46d43",
            "#d73027",
            "#a50026",
        ],
    ))
    line3d.add(
        "",
        _data,
        xaxis3d_opts=opts.Axis3DOpts(data=clock, type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(data=week_en, type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
    )
    return line3d
Ejemplo n.º 26
0
def scatter3d_base():
    data = [
        [random.randint(0, 100),
         random.randint(0, 100),
         random.randint(0, 100)]
        for _ in range(80)
    ]
    scatter3d = Scatter3D(init_opts=opts.InitOpts(width="1440px", height="720px"))
    scatter3d.add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(type_="value")
    )
    scatter3d.set_global_opts(
        visualmap_opts=opts.VisualMapOpts(),
        title_opts=opts.TitleOpts(title="Scatter3D-基本示例")
    )
    scatter3d.render("./scatter3d_base.html")
Ejemplo n.º 27
0
 def plot(self):
     self.data_process()
     self.gragh.add(
         # series name
         "",
         # 通过k*k循环展开测出来的数据集
         data=self.data_set,
         # 三维图形的着色效果配置,realistic即为真实感渲染
         shading="realistic",
         # 图元配置项
         itemstyle_opts=opts.ItemStyleOpts(),
         # 3D X坐标轴配置项
         xaxis3d_opts=opts.Axis3DOpts(name="步长", name_gap=40),
         # 3D Y坐标轴配置项
         yaxis3d_opts=opts.Axis3DOpts(name="大小/B", name_gap=40),
         # 3D Z坐标轴配置项
         zaxis3d_opts=opts.Axis3DOpts(name="存储器读取速度MB/s", name_gap=40),
         # 三维笛卡尔坐标系配置项
         grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
     ).set_global_opts(title_opts=opts.TitleOpts(
         title="Memory Mountain K*K Loop unrolling",
         pos_left="center",
         pos_top=90,
     ),
                       visualmap_opts=opts.VisualMapOpts(
                           dimension=3,
                           max_=1,
                           min_=-1,
                           range_color=[
                               "#313695",
                               "#4575b4",
                               "#74add1",
                               "#abd9e9",
                               "#e0f3f8",
                               "#ffffbf",
                               "#fee090",
                               "#fdae61",
                               "#f46d43",
                               "#d73027",
                               "#a50026",
                           ],
                       )).render()
Ejemplo n.º 28
0
 def plot(self):
     self.chart = Bar3D(init_opts=opts.InitOpts(page_title=self.title))
     self.chart.add(
         self.zaxis_name,
         [[d[1], d[0], d[2]] for d in self.heat_map],
         xaxis3d_opts=opts.Axis3DOpts(self.data_y,
                                      type_="category",
                                      name=self.yaxis_name,
                                      name_gap=25),
         yaxis3d_opts=opts.Axis3DOpts(self.data_x,
                                      type_="category",
                                      name=self.xaxis_name,
                                      name_gap=25),
         zaxis3d_opts=opts.Axis3DOpts(type_="value"),
     )
     self.chart.set_global_opts(title_opts=opts.TitleOpts(title=self.title),
                                visualmap_opts=opts.VisualMapOpts(
                                    max_=self.max_value,
                                    min_=self.min_value))
     return self
Ejemplo n.º 29
0
def line3d_base():
    data = []
    for t in range(0, 25000):
        _t = t / 1000
        x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
        y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
        z = _t + 2.0 * math.sin(75 * _t)
        data.append([x, y, z])
    line3d = Line3D()
    line3d.add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100, depth=100),
    )
    line3d.set_global_opts(
        title_opts=opts.TitleOpts(title="Line3D-基本示例"),
        visualmap_opts=opts.VisualMapOpts(max_=30)
    )
    line3d.render("./line3d_base.html")
Ejemplo n.º 30
0
def scatter3d_base() -> Scatter3D:
    # data = [
    #     [random.randint(0, 100), random.randint(0, 200), random.randint(0, 100)]
    #     for _ in range(10000)
    # ]
    data, max_rel = read_as_info(
        '..\\000LocalData\\as_compare\\as_core_map_data_integrate20191203.csv')
    c = (Scatter3D(init_opts=opts.InitOpts(
        width="1080px",
        height="1080px",
        page_title="全球互联网网络3D散点图",
        theme=ThemeType.ROMANTIC)).add(
            "随机散点",
            data,
            grid3d_opts=opts.Grid3DOpts(width=300,
                                        height=160,
                                        depth=300,
                                        rotate_speed=5,
                                        is_rotate=True,
                                        rotate_sensitivity=2),
            xaxis3d_opts=opts.Axis3DOpts(type_="value",
                                         name="经度",
                                         min_=180.0,
                                         max_=-180.0),
            yaxis3d_opts=opts.Axis3DOpts(type_="value",
                                         name="维度",
                                         min_=-180.0,
                                         max_=180.0),
            zaxis3d_opts=opts.Axis3DOpts(type_="value",
                                         name="连通度",
                                         min_=0,
                                         max_=max_rel + 1),
            itemstyle_opts=opts.ItemStyleOpts()).set_global_opts(
                title_opts=opts.TitleOpts("全球互联网网络3D散点图"),
                visualmap_opts=opts.VisualMapOpts(
                    range_color=Faker.visual_color),
            ))
    print(data)
    print(Faker.visual_color)
    return c