def drawThreeD(data, mode, time):
    bar3d = Bar3D()
    temp = list(arrangeByTime(data).get(time).keys())
    res = []
    data = arrangeByChannel(data)  # 按频道分
    news = dict()
    for i in data.keys():
        news[i] = arrangeByTime(data.get(i)).get(time)
    value = dict()
    comment_channel = dict()
    for i in news.keys():
        comment_channel[i] = dict()
        value[i] = dict()
        for j in news[i].keys():
            comment_channel[i][j] = divideComment(news[i].get(j))
        value[i] = getMood(comment_channel[i], mode)
    for i in value.keys():
        if i in ['js', 'jilin', 'video', 'live']:
            continue
        if len(value.get(i)) == 0:
            continue
        for j in temp:
            if j in value.get(i).keys():
                res.append((tran(i), j, value.get(i).get(j)))
            else:
                res.append((tran(i), j, None))
    bar3d.add(
        "",
        [[d[1], d[0], d[2]] for d in res],
    ).set_global_opts(
        visualmap_opts=options.VisualMapOpts(max_=1),
        title_opts=options.TitleOpts(title="时间、维度与新浪评论情感总图"),
    )
    return bar3d
Пример #2
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
    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
Пример #4
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
Пример #5
0
def bar3d_base():
    data = [[i, j, random.randint(0, 20)] for i in Faker.clock for j in Faker.week]
    bar3d = Bar3D(init_opts=opts.InitOpts(width='1100px', height='600px'))
    bar3d.add(" ", data)
    bar3d.set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=20),
        title_opts=opts.TitleOpts(title="Bar_3D-基本实例")
    )
    bar3d.render("./bar_3d_base.html")
Пример #6
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
Пример #7
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')
Пример #8
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()
Пример #9
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
Пример #10
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
Пример #11
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
Пример #12
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
Пример #13
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
Пример #14
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")
Пример #15
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
Пример #16
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")
Пример #17
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
Пример #18
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
Пример #20
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"))
Пример #21
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
Пример #22
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
Пример #23
0
def test_bar3d_stack(fake_writer):
    data1 = [(i, j, random.randint(0, 12)) for i in range(6)
             for j in range(24)]
    data2 = [(i, j, random.randint(13, 20)) for i in range(6)
             for j in range(24)]
    c = (Bar3D().add(
        "1",
        [[d[1], d[0], d[2]] for d in data1],
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).add(
        "2",
        [[d[1], d[0], d[2]] for d in data2],
        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)).set_series_opts(**{"stack": "stack"}))
    c.render()
    _, content = fake_writer.call_args[0]
    assert_in("stack", content)
Пример #24
0
def draw():
    code = []
    for ch in ["A", "B", "C", "D", "E"]:
        for i in range(1, 11):
            code.append(ch + "-" + str(i))
    k_value = ["recall@1", "recall@5", "recall@10"]
    recall_value = []
    plot_data = []
    for i in range(len(code)):
        for j in range(len(k_value)):
            plot_data.append((code[i], k_value[j], random.uniform(0, 1)))
    c = (Bar3D().add(
        "Sample",
        plot_data,
        xaxis3d_opts=opts.Axis3DOpts(code, type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(k_value, type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(type_="value"),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=1),
        title_opts=opts.TitleOpts(title="50 Sample Recall"),
    ))
    return c
Пример #25
0
def bar_3d_fun():
    # 三维数据,定义 x、y 长度,z 数值随机
    data = [(i, j, random.randint(1, 20)) for i in range(7) for j in range(10)]
    print(len(data), data)
    Bar3D().add(
        # 添加 x、y、z 轴数据,并设置属性
        series_name="",
        data=data,
        xaxis3d_opts=opts.Axis3DOpts(Faker.choose(), type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.choose(), type_="category"),
        zaxis3d_opts=opts.Axis3DOpts(Faker.values(), type_="value"),
        # 添加旋转效果
        grid3d_opts=opts.Grid3DOpts(width=100,
                                    depth=100,
                                    rotate_speed=150,
                                    is_rotate=True),
    ).set_global_opts(
        # 设置图表属性
        # 视觉配置
        visualmap_opts=opts.VisualMapOpts(max_=20),
        title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")).render(
            # 设置输出路径
            path="D:/temp/pyecharts_bar3d.html")
Пример #26
0
hours = ["厚度1", "厚度2", "厚度3", "厚度4", "厚度5", "厚度6", "厚度7", "厚度8", "厚度9", "平均厚度"]
days = ["1", "2", "3", "4", "5", "6", "7"]

data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]
data = [[d[1], d[0], d[2]] for d in data]

c = (Bar3D(init_opts=opts.InitOpts(width="900px", height="600px")).add(
    series_name="",
    data=data,
    xaxis3d_opts=opts.Axis3DOpts(type_="category", data=hours),
    yaxis3d_opts=opts.Axis3DOpts(type_="category", data=days),
    zaxis3d_opts=opts.Axis3DOpts(type_="value"),
).set_global_opts(title_opts=opts.TitleOpts("标准3D柱状图"),
                  visualmap_opts=opts.VisualMapOpts(
                      max_=20,
                      range_color=[
                          "#313695",
                          "#4575b4",
                          "#74add1",
                          "#abd9e9",
                          "#e0f3f8",
                          "#ffffbf",
                          "#fee090",
                          "#fdae61",
                          "#f46d43",
                          "#d73027",
                          "#a50026",
                      ],
                  )).render("标准3D柱状图.html"))
c.render_notebook()
Пример #27
0
    Bar3D(init_opts = opts.InitOpts(width = "1600px", height = "800px"))
        .add(
        series_name = "",
        data = data,
        xaxis3d_opts = opts.Axis3DOpts(type_ = "category", data = Elec_kinds_X,
                                       name = "Power type (left : XJ & right : ZJ)"),
        yaxis3d_opts = opts.Axis3DOpts(type_ = "category", data = Indicator_Y, name = "Indicator type",name_gap = 30),
        zaxis3d_opts = opts.Axis3DOpts(type_ = "value", name = "Points"),
        # label_opts = opts.LabelOpts(is_show = True)
        # 数据标签显示

    )
        .set_global_opts(
        visualmap_opts = opts.VisualMapOpts(
            max_ = 0.12,
            range_color = [
                "#313695",
                "#4575b4",
                "#74add1",
                "#abd9e9",
                "#e0f3f8",
                "#ffffbf",
                "#fee090",
                "#fdae61",
                "#f46d43",
                "#d73027",
                "#a50026",
            ],
        )
    )
        .render("endpoint1.html")
# In[147]:

# vis
import random

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

data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]
bar3d = (
    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-基本示例"),
    )
    #.render("bar3d_base.html")
)

bar3d.render_notebook()

# ## EffectScatter

# In[116]:

# vis
from pyecharts import options as opts
Пример #29
0
 def to_map_china(self, area, variate, value, update_time):
     # 显示标识栏的颜色分段表示
     pieces = [
         {
             "max": 99999999,
             "min": 10000,
             "label": '>10000',
             "color": '#E64546'
         },
         {
             "max": 9999,
             "min": 1000,
             "label": '1000-9999',
             "color": '#F57567'
         },
         {
             "max": 999,
             "min": 100,
             "label": '100-999',
             "color": '#FF9985'
         },
         {
             "max": 99,
             "min": 10,
             "label": '10-99',
             "color": '#FFC4B3'
         },
         {
             "max": 9,
             "min": 1,
             "label": '1-9',
             "color": '#FFE5DB'
         },
         {
             "max": 0,
             "min": 0,
             "label": '0',
             "color": '#FFFFFF'
         },
     ]
     data_tip = [
         '累计确诊', '死亡', '治愈', '现有确诊', '累计确诊增量', '死亡增量', '治愈增量', '现有确诊增量'
     ]
     data_area = [
         '西藏', '澳门', '青海', '台湾', '香港', '贵州', '吉林', '新疆', '宁夏', '内蒙古', '甘肃',
         '天津', '山西', '辽宁', '黑龙江', '海南', '河北', '陕西', '云南', '广西', '福建', '上海',
         '北京', '江苏', '四川', '山东', '江西', '重庆', '安徽', '湖南', '河南', '广东', '浙江',
         '湖北'
     ]
     # 绘制地图
     map = (
         Map(init_opts=opts.InitOpts(width='800px',
                                     height='600px'))  # 初始化配置项,设置地图大小
         .add("累计确诊人数", [
             list(z) for z in zip(area, variate)
         ], "china").set_global_opts(
             title_opts=opts.TitleOpts(title="中国疫情地图分布",
                                       subtitle='截止%s 中国疫情分布情况' %
                                       (update_time),
                                       pos_left='center',
                                       pos_top='30px'),  #TitleOpts:标题设置
             visualmap_opts=opts.VisualMapOpts(max_=200,
                                               is_piecewise=True,
                                               pieces=pieces),
             # # max_:设置 visualMapPiecewise 所有取值区间中的最大值,is_piecewise设置数据是否连续,split_number设置为分段数,pices可自定义数据分段
         ).render("中国疫情地图.html")  # 展示提取后的效果
     )
     # 绘制地理坐标图
     geo = (
         Geo().add_schema(maptype="china")  #地图类型
         .add(
             "累计确诊人数",
             [list(z) for z in zip(area, variate)],
             type_=ChartType.EFFECT_SCATTER,
         ).set_series_opts(label_opts=opts.LabelOpts(
             is_show=False))  # label_opts:标签配置项设置,is_show:是否显示视觉映射配置
         .set_global_opts(
             title_opts=opts.TitleOpts(title="中国疫情地图分布",
                                       subtitle='截止%s 中国疫情分布情况' %
                                       (update_time),
                                       pos_left='center',
                                       pos_top='30px'),
             visualmap_opts=opts.VisualMapOpts(max_=200,
                                               is_piecewise=True,
                                               pieces=pieces),
         ).render("中国疫情新增情况.html"))
     # 绘制折线图
     line = (
         Line().add_xaxis(area)  #添加x轴数值
         .add_yaxis("累计确诊人数", variate)  #添加y轴名称、数值
         .add_yaxis("累计治愈人数", value).set_global_opts(
             title_opts=opts.TitleOpts(title="国内疫情情况"),
             xaxis_opts=opts.AxisOpts(axislabel_opts={
                 "interval": "0",
                 "rotate": "45"
             }),  #设置x轴数值分割间隔为0,且旋转45°
             yaxis_opts=opts.AxisOpts(
                 type_='log',
                 splitline_opts=opts.SplitLineOpts(is_show=True),
                 is_scale=True,
             )  #设置y轴数据类型为“log”,凸显分割线,不会强制包含零刻度
         ).set_series_opts(label_opts=opts.LabelOpts(is_show=False))  #标签设置项
         .render("全国累计趋势折线图.html"))
     # 绘制柱状图
     bar = (
         Bar().add_xaxis(area).add_yaxis(
             "累计确诊人数", variate,
             stack='stack1')  #若y轴设置项“stack”为同一个值,则显示为堆叠型柱状,反之,成分散型
         # .add_yaxis("累计治愈人数",value,stack='stack2')
         # .add_yaxis("累计死亡人数", value, stack='stack1')
         .add_yaxis("累计治愈人数", value, stack='stack1').set_global_opts(
             title_opts=opts.TitleOpts(title="全国累计确诊治愈情况"),
             xaxis_opts=opts.AxisOpts(axislabel_opts={
                 "interval": "0",
                 "rotate": "45"
             }),
             yaxis_opts=opts.AxisOpts(
                 type_='log',
                 splitline_opts=opts.SplitLineOpts(is_show=True),
                 is_scale=True,
             )).set_series_opts(label_opts=opts.LabelOpts(
                 is_show=False)).render("全国累计确诊治愈.html"))
     # 绘制饼状图
     pie = (
         Pie().add(
             "",
             [list(z) for z in zip(area, variate)],
             radius=["40%", "75%", "log"],  #设置圆环大小及数据类型
         ).set_global_opts(
             title_opts=opts.TitleOpts(title="国内疫情情况"),
             legend_opts=opts.LegendOpts(orient="vertical",
                                         pos_top="15%",
                                         pos_left="2%"),
             #图例配置项:图例列表的布局朝向为水平,图例组件离容器上侧的距离为15%,图例组件离容器左侧的距离为相对于容器高宽的20%
         ).set_series_opts(
             label_opts=opts.LabelOpts(formatter="{b}: {c}"))  #设置标签形式
         .render("全国累计趋势饼状图.html"))
     # 绘制3D柱状图
     bar3d = (
         Bar3D().add("全国指标",
                     data,
                     label_opts=opts.LabelOpts(position='left'),
                     yaxis3d_opts=opts.Axis3DOpts(data_area),
                     xaxis3d_opts=opts.Axis3DOpts(
                         data_tip,
                         type_="category",
                         max_=8,
                         interval=0,
                     ),
                     zaxis3d_opts=opts.Axis3DOpts(type_="value", min_=0),
                     grid3d_opts=opts.Grid3DOpts(width="600",
                                                 height="100",
                                                 is_rotate=True)
                     #设置三维笛卡尔坐标系组件在三维场景中的宽度,高度,以及是否自动旋转
                     ).set_global_opts(
                         visualmap_opts=opts.VisualMapOpts(
                             is_piecewise=True, pieces=pieces),
                         title_opts=opts.TitleOpts(title="疫情指标"),
                     ).render("疫情指标.html"))
Пример #30
0
from pyecharts.charts import Bar3D
from pyecharts.faker import Faker  #虚构的数据
from pyecharts import options as opts  #配置
from pyecharts.charts import Bar  #导入bar图
from pyecharts.globals import ThemeType
import random

data = [(i, j, random.randint(0, 12)) for i in range(24) for j in range(24)]

bar3d = Bar3D()
bar3d.add(
    "",
    data,
    xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
    yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),
    zaxis3d_opts=opts.Axis3DOpts(type_="value"),
)

bar3d.set_global_opts(
    visualmap_opts=opts.VisualMapOpts(max_=20),
    title_opts=opts.TitleOpts(title="Bar3D-基本示例"),
)
bar3d.render()