pyecharts柱状图进阶篇
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pyecharts柱状图进阶篇相关的知识,希望对你有一定的参考价值。
参考技术A 如果想把温度和降雨量画在同一个柱状图内,一个纵坐标就不够用了import pyecharts.options as opts
from pyecharts.charts import Bar, Line
x_data = ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]
bar = (
Bar(init_opts=opts.InitOpts(width="1000px", height="600px"))
.add_xaxis(xaxis_data=x_data)
.add_yaxis(
series_name="蒸发量",
yaxis_data=[2.0,4.9,7.0,23.2,25.6,76.7,135.6,162.2,32.6,20.0,6.4,3.3,],
label_opts=opts.LabelOpts(is_show=False),
)
.add_yaxis(
series_name="平均温度",
yaxis_data=[2.0,2.2,3.3,4.5,6.3,10.2,20.3,23.4,23.0,16.5,12.0,6.2],
label_opts=opts.LabelOpts(is_show=False),
)
yaxis=opts.AxisOpts(
name="温度",
type_="value",
min_=0,
max_=25,
interval=5,
axislabel_opts=opts.LabelOpts(formatter="value °C"),
)
)
.set_global_opts(
tooltip_opts=opts.TooltipOpts(
is_show=True, trigger="axis", axis_pointer_type="cross"
),
xaxis_opts=opts.AxisOpts(
type_="category",
axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"),
),
yaxis_opts=opts.AxisOpts(
name="水量",
type_="value",
min_=0,
max_=250,
interval=50,
axislabel_opts=opts.LabelOpts(formatter="value ml"),
axistick_opts=opts.AxisTickOpts(is_show=True),
splitline_opts=opts.SplitLineOpts(is_show=True),
),
)
)
bar.render_notebook()
简单的出场方式已经不能满足我的需要了,我需要酷炫一点的
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.faker import Faker
l1=[100,200,300,400,500,400,300]
l2=[300,400,500,400,300,200,100]
bar = (
Bar(
init_opts=opts.InitOpts(
animation_opts=opts.AnimationOpts(
animation_delay=1000, animation_easing="bounceIn"
)
)
)
.add_xaxis(Faker.choose())
.add_yaxis("商家A", l1)
.add_yaxis("商家B", l2)
.set_global_opts(title_opts=opts.TitleOpts(title="Bar-动画配置基本示例", subtitle="我是副标题"))
)
bar.render_notebook()
以上是关于pyecharts柱状图进阶篇的主要内容,如果未能解决你的问题,请参考以下文章