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()
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()
默认不显示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()
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()
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()
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()
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()
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()
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()