当前位置: 首页>>代码示例>>Python>>正文


Python Bar.add方法代码示例

本文整理汇总了Python中pyecharts.Bar.add方法的典型用法代码示例。如果您正苦于以下问题:Python Bar.add方法的具体用法?Python Bar.add怎么用?Python Bar.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyecharts.Bar的用法示例。


在下文中一共展示了Bar.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_grid_four_direction

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_grid_four_direction():
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720, width=1200, title_pos="65%")
    bar.add("商家A", CLOTHES, v1, is_stack=True)
    bar.add("商家B", CLOTHES, v2, is_stack=True, legend_pos="80%")
    line = Line("折线图示例")
    line.add("最高气温", WEEK, [11, 11, 15, 13, 12, 13, 10],
             mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", WEEK, [1, -2, 2, 5, 3, 2, 0],
             mark_point=["max", "min"], mark_line=["average"],
             legend_pos="20%")
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    scatter = Scatter("散点图示例", title_top="50%", title_pos="65%")
    scatter.add("scatter", v1, v2, legend_top="50%", legend_pos="80%")
    es = EffectScatter("动态散点图示例", title_top="50%")
    es.add("es", [11, 11, 15, 13, 12, 13, 10], [1, -2, 2, 5, 3, 2, 0],
           effect_scale=6, legend_top="50%", legend_pos="20%")

    grid = Grid()
    grid.add(bar, grid_bottom="60%", grid_left="60%")
    grid.add(line, grid_bottom="60%", grid_right="60%")
    grid.add(scatter, grid_top="60%", grid_left="60%")
    grid.add(es, grid_top="60%", grid_right="60%")
    grid.render()
开发者ID:chumingke,项目名称:pyecharts,代码行数:28,代码来源:test_grid.py

示例2: test_grid_add_overlap

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_grid_add_overlap():
    from pyecharts import Overlap

    grid = Grid()

    attr = ["{}月".format(i) for i in range(1, 13)]
    v1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
    v2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
    v3 = [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]

    bar = Bar("Overlap+Grid 示例", width=1200, height=600, title_pos="40%")
    bar.add("蒸发量", attr, v1)
    bar.add(
        "降水量",
        attr,
        v2,
        yaxis_formatter=" ml",
        yaxis_max=250,
        legend_pos="85%",
        legend_orient="vertical",
        legend_top="45%",
    )

    line = Line()
    line.add("平均温度", attr, v3, yaxis_formatter=" °C")

    overlap = Overlap()
    overlap.add(bar)
    overlap.add(line, is_add_yaxis=True, yaxis_index=1)

    grid.add(overlap, grid_right="20%")
    grid.render()
开发者ID:Jesszen,项目名称:pyecharts,代码行数:34,代码来源:test_grid.py

示例3: test_grid_top_bottom

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_grid_top_bottom():
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720)
    bar.add("商家A", CLOTHES, v1, is_stack=True)
    bar.add("商家B", CLOTHES, v2, is_stack=True)
    line = Line("折线图示例", title_top="50%")
    line.add(
        "最高气温",
        WEEK,
        [11, 11, 15, 13, 12, 13, 10],
        mark_point=["max", "min"],
        mark_line=["average"],
    )
    line.add(
        "最低气温",
        WEEK,
        [1, -2, 2, 5, 3, 2, 0],
        mark_point=["max", "min"],
        mark_line=["average"],
        legend_top="50%",
    )

    grid = Grid()
    grid.add(bar, grid_bottom="60%")
    grid.add(line, grid_top="60%")
    grid.render()
开发者ID:Jesszen,项目名称:pyecharts,代码行数:29,代码来源:test_grid.py

示例4: test_bar_stack

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_bar_stack():
    bar = Bar("柱状图数据堆叠示例")
    bar.add("商家A", CLOTHES, clothes_v1, is_stack=True)
    bar.add("商家B", CLOTHES, clothes_v2, is_stack=True)
    html_content = bar._repr_html_()
    assert "dataZoom" not in html_content
    assert "stack_" in html_content
开发者ID:chumingke,项目名称:pyecharts,代码行数:9,代码来源:test_bar.py

示例5: ax_draw_macd

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def ax_draw_macd(axes, kdata, n1=12, n2=26, n3=9):
    """绘制MACD
    
    :param axes: 指定的坐标轴
    :param KData kdata: KData
    :param int n1: 指标 MACD 的参数1
    :param int n2: 指标 MACD 的参数2
    :param int n3: 指标 MACD 的参数3
    """
    macd = MACD(CLOSE(kdata), n1, n2, n3)
    bmacd, fmacd, smacd = macd.getResult(0), macd.getResult(1), macd.getResult(2)
    
    text = 'MACD(%s,%s,%s) DIF:%.2f, DEA:%.2f, BAR:%.2f'%(n1,n2,n3,fmacd[-1],smacd[-1],bmacd[-1])
    #axes.text(0.01,0.97, text, horizontalalignment='left', verticalalignment='top', transform=axes.transAxes)
    total = len(kdata)
    x_list = [i for i in range(total)]
    y1_list = [round(x) if x > 0 else '-' for x in bmacd]
    y2_list = [round(x) if x <= 0 else '-' for x in bmacd]
    
    style = gcf().get_style(axes)
    bar = Bar(subtitle=text, title_pos='10%', title_top='8%')
    bar.add('1', x_list, y1_list, is_stack=True, is_legend_show=False, **style)
    bar.add('2', x_list, y2_list, is_stack=True, is_legend_show=False, **style)
    
    axes.add(bar)
    fmacd.plot(axes=axes, line_type='dotted')
    smacd.plot(axes=axes)

    gcf().add_axis(axes)
    return gcf()
开发者ID:fasiondog,项目名称:hikyuu,代码行数:32,代码来源:echart_draw.py

示例6: test_timeline_label_color

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_timeline_label_color():
    attr = ["{}月".format(i) for i in range(1, 7)]
    bar = Bar("1 月份数据", "数据纯属虚构")
    bar.add(
        "bar",
        attr,
        [randint(10, 50) for _ in range(6)],
        label_color=["red", "#213", "black"],
    )
    line = Line()
    line.add("line", attr, [randint(50, 80) for _ in range(6)])
    overlap_0 = Overlap()
    overlap_0.add(bar)
    overlap_0.add(line)

    bar_1 = Bar("2 月份数据", "数据纯属虚构")
    bar_1.add("bar", attr, [randint(10, 50) for _ in range(6)])
    line_1 = Line()
    line_1.add("line", attr, [randint(50, 80) for _ in range(6)])
    overlap_1 = Overlap()
    overlap_1.add(bar_1)
    overlap_1.add(line_1)

    timeline = Timeline(timeline_bottom=0)
    timeline.add(overlap_0, "1 月")
    timeline.add(overlap_1, "2 月")
    content = timeline._repr_html_()
    assert '"color": [' in content
    assert "red" in content
    assert "#213" in content
    assert "black" in content
开发者ID:Jesszen,项目名称:pyecharts,代码行数:33,代码来源:test_timeline.py

示例7: create_a_bar

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def create_a_bar(title):
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar(title)
    bar.add("商家A", CLOTHES, v1, is_stack=True)
    bar.add("商家B", CLOTHES, v2, is_stack=True)
    return bar
开发者ID:Jesszen,项目名称:pyecharts,代码行数:9,代码来源:test_notebook.py

示例8: create_three

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def create_three():
    page = Page(page_title=TEST_PAGE_TITLE)

    # bar
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图数据堆叠示例")
    bar.add("商家A", CLOTHES, v1, is_stack=True)
    bar.add("商家B", CLOTHES, v2, is_stack=True)
    page.add(bar)

    # scatter3D
    import random
    data = [
        [random.randint(0, 100),
         random.randint(0, 100),
         random.randint(0, 100)] for _ in range(80)
        ]
    scatter3d = Scatter3D("3D 散点图示例", width=1200, height=600)
    scatter3d.add("", data, is_visualmap=True, visual_range_color=RANGE_COLOR)
    page.add(scatter3d)

    # guangdong
    value = [20, 190, 253, 77, 65]
    attr = ['汕头市', '汕尾市', '揭阳市', '阳江市', '肇庆市']
    map = Map("广东地图示例", width=1200, height=600)
    map.add("", attr, value, maptype='广东', is_visualmap=True,
            visual_text_color='#000')
    page.add(map)

    return page
开发者ID:chumingke,项目名称:pyecharts,代码行数:33,代码来源:test_page.py

示例9: test_bar_rotate_label

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_bar_rotate_label():
    days = ["{}天".format(i) for i in range(20)]
    days_v1 = [random.randint(1, 20) for _ in range(20)]
    bar = Bar("坐标轴标签旋转示例")
    bar.add("", days, days_v1, xaxis_interval=0, xaxis_rotate=30,
            yaxis_rotate=30)
    assert "stack_" not in bar._repr_html_()
开发者ID:chumingke,项目名称:pyecharts,代码行数:9,代码来源:test_bar.py

示例10: test_numpy_array

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_numpy_array():
    v1 = np.array([5, 20, 36, 10, 75, 90])
    bar = Bar(TITLE)
    bar.add("商家A", CLOTHES, v1, is_stack=True)
    html = bar.render_embed()
    json_encoded_title = json.dumps(TITLE)
    assert json_encoded_title in html
开发者ID:MandyCh,项目名称:pyecharts,代码行数:9,代码来源:test_base.py

示例11: test_grid_properties

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_grid_properties():
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720)
    bar.add("商家A", CLOTHES, v1, is_stack=True)
    bar.add("商家B", CLOTHES, v2, is_stack=True)
    line = Line("折线图示例", title_top="50%")
    line.add(
        "最高气温",
        WEEK,
        [11, 11, 15, 13, 12, 13, 10],
        mark_point=["max", "min"],
        mark_line=["average"],
    )
    line.add(
        "最低气温",
        WEEK,
        [1, -2, 2, 5, 3, 2, 0],
        mark_point=["max", "min"],
        mark_line=["average"],
        legend_top="50%",
    )

    grid = Grid(width=1024, height=768)
    grid.add(bar, grid_bottom="60%")
    grid.add(line, grid_top="60%")
    eq_(grid.width, 1024)
    eq_(grid.height, 768)
    assert (
        ("echarts" in bar.js_dependencies)
        or ("echarts.min" in bar.js_dependencies)
    )
开发者ID:Jesszen,项目名称:pyecharts,代码行数:34,代码来源:test_chart_properties.py

示例12: test_custom_template_for_chart

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_custom_template_for_chart():
    data = [{
        'name': '衬衫',
        'value': 5
    }, {
        'name': '羊毛衫',
        'value': 20
    }, {
        'name': '雪纺衫',
        'value': 36
    }]

    configure(echarts_template_dir='.')

    online()

    data1 = {'衬衫': '34', '羊毛衫': 45, '雪纺衫': 40}
    names, values = Bar.cast(data)
    names1, values1 = Bar.cast(data1)
    bar = Bar("柱状图数据堆叠示例")
    bar.add("商家A", names, values, is_stack=True)
    bar.add("商家B", names1, values1, is_stack=True)
    bar.render(path='new_version_bar.html')
    with codecs.open('new_version_bar.html', 'r', 'utf-8') as f:
        actual_content = f.read()
        assert "</html>" in actual_content
开发者ID:chumingke,项目名称:pyecharts,代码行数:28,代码来源:test_custom_render.py

示例13: test_bar_datazoom_undefined

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_bar_datazoom_undefined():
    days = ["{}天".format(i) for i in range(30)]
    days_v1 = [random.randint(1, 30) for _ in range(30)]
    bar = Bar("Bar - datazoom 默认 示例")
    bar.add("", days, days_v1, is_label_show=True, is_datazoom_show=True)
    html_content = bar._repr_html_()
    assert "dataZoom" in html_content
    assert ': "slider"' in html_content
    assert ': "inside"' not in html_content
开发者ID:chumingke,项目名称:pyecharts,代码行数:11,代码来源:test_bar.py

示例14: test_bar_datazoom_inside

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def test_bar_datazoom_inside():
    days = ["{}天".format(i) for i in range(30)]
    days_v1 = [random.randint(1, 30) for _ in range(30)]
    bar = Bar("Bar - datazoom - inside 示例")
    bar.add("", days, days_v1, is_datazoom_show=True,
            datazoom_type='inside', datazoom_range=[10, 25])
    html_content = bar._repr_html_()
    assert "dataZoom" in html_content
    assert ': "inside"' in html_content
    assert ': "slider"' not in html_content
开发者ID:chumingke,项目名称:pyecharts,代码行数:12,代码来源:test_bar.py

示例15: create_demo_bar

# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import add [as 别名]
def create_demo_bar(chart_id_demo=None):
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图数据堆叠示例")
    bar.add("商家A", attr, v1, is_stack=True)
    bar.add("商家B", attr, v2, is_stack=True)
    if chart_id_demo:
        bar._chart_id = chart_id_demo
    return bar
开发者ID:MandyCh,项目名称:pyecharts,代码行数:12,代码来源:test_template_function.py


注:本文中的pyecharts.Bar.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。