pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)

一、bar基本示例

1.1基本对比图例

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar

bar=(
    Bar()
        .add_xaxis(Faker.choose())
        .add_yaxis("商家A", Faker.values())
        .add_yaxis("商家B", Faker.values())
        .set_global_opts(title_opts=opts.TitleOpts(title="Bar-基本示例", subtitle="我是副标题"))
    )

bar.render()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第1张图片

1.1.2 翻转 XY 轴

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar

bar=(
    Bar()
        .add_xaxis(Faker.choose())
        .add_yaxis("商家A", Faker.values())
        .add_yaxis("商家B", Faker.values())
        .reversal_axis()
        .set_series_opts(label_opts=opts.LabelOpts(position="right"))
        .set_global_opts(title_opts=opts.TitleOpts(title="Bar-翻转 XY 轴"))
    )

bar.render()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第2张图片

1.3 默认取消某series

默认不显示B的商品

from pyecharts import options as opts
from pyecharts.charts import Bar
c =(
Bar().add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
    .add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
    .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49],is_selected=False)
    .set_global_opts(title_opts=opts.TitleOpts(title='Bar-基本展示',subtitle='我是副标题'))




)
c.render_notebook()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第3张图片

二、Bar-堆叠数据(全部)

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar

bar=(
    Bar()
        .add_xaxis(Faker.choose())
        .add_yaxis("商家A", Faker.values(), stack="stack1")
        .add_yaxis("商家B", Faker.values(), stack="stack1")
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(title_opts=opts.TitleOpts(title="Bar-堆叠数据(全部)"))
    )

bar.render()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第4张图片

Bar-MarkLine(加标签、平均线、最大基准线、最小基准线)

from pyecharts.charts import Bar
c =(
Bar().add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"]).
     add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49])
    .set_global_opts(title_opts=opts.TitleOpts(title='Bar-MARKline显示数据'))
    .set_series_opts(
    label_opts=opts.LabelOpts(is_show=False),
        markline_opts=opts.MarkLineOpts(
                data=[
                    opts.MarkLineItem(type_="min", name="最小值"),
                    opts.MarkLineItem(type_="max", name="最大值"),
                    opts.MarkLineItem(type_="average", name="平均值"),
                ]
            ),
    
    
    
    
    )





)
c.render_notebook()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第5张图片
Bar-MarkPoint(指定类型)

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar

bar=(
    Bar()
        .add_xaxis(Faker.choose())
        .add_yaxis("商家A", Faker.values())
        .add_yaxis("商家B", Faker.values())
        .set_global_opts(title_opts=opts.TitleOpts(title="Bar-MarkPoint(指定类型)"))
        .set_series_opts(
            label_opts=opts.LabelOpts(is_show=False),
            markpoint_opts=opts.MarkPointOpts(
                data=[
                    opts.MarkPointItem(type_="max", name="最大值"),
                    opts.MarkPointItem(type_="min", name="最小值"),
                    opts.MarkPointItem(type_="average", name="平均值"),
                ]
            ),
        )
    )

bar.render()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第6张图片

Bar-DataZoom(slider-水平)

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar

bar=(
    Bar()
        .add_xaxis(Faker.days_attrs)
        .add_yaxis("商家A", Faker.days_values)
        .set_global_opts(
            title_opts=opts.TitleOpts(title="Bar-DataZoom(slider-水平)"),
            datazoom_opts=opts.DataZoomOpts(),
        )
    )

bar.render()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第7张图片

Bar-DataZoom(slider-垂直)

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar

bar=(
    Bar()
        .add_xaxis(Faker.days_attrs)
        .add_yaxis("商家A", Faker.days_values, color=Faker.rand_color())
        .set_global_opts(
            title_opts=opts.TitleOpts(title="Bar-DataZoom(slider-垂直)"),
            datazoom_opts=opts.DataZoomOpts(orient="vertical"),
        )
    )

bar.render()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第8张图片

显示工具箱

from pyecharts.charts import Bar
c =(
Bar().add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"]).
    add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49])
     .set_global_opts(
            title_opts=opts.TitleOpts(title="Bar-显示 ToolBox"),
            toolbox_opts=opts.ToolboxOpts(),
            legend_opts=opts.LegendOpts(is_show=False)
        )


)
c.render_notebook()

pyecharts (1.0+版本)绘制 柱状图/条形图 Bar————————学习笔记(不断更新中)_第9张图片

bar - markline 指定类型(划横线那种)

你可能感兴趣的:(可视化,jupyter,notebook,python)