最近学习怎么pyecharts,结果出来的图是这样的
temp_prey = [a1,a2,a3,a4,a5,a6,a7,a8,a9]
temp_hunter = [b1,b2,b3,b4,b5,b6,b7,b8,b9]
# print(temp_prey)
# print(temp_hunter)
c = (
Line()
.add_xaxis([0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9])
.add_yaxis("捕食者", temp_hunter, is_smooth=True)
.add_yaxis("猎物", temp_prey, is_smooth=True)
.set_series_opts(
# areastyle_opts=opts.AreaStyleOpts(opacity=0.5),
label_opts=opts.LabelOpts(is_show=False),
)
.set_global_opts(
title_opts=opts.TitleOpts(title="Line"),
xaxis_opts=opts.AxisOpts(
axistick_opts=opts.AxisTickOpts(is_align_with_label=True),
is_scale=False,
boundary_gap=False,
),
)
.render("line_areastyle_boundary_gap.html")
)
这是我的代码
将add_xaxis()中数改成字符串形式看看
from pyecharts.charts import Line
from pyecharts import options as opts
temp_prey = [2,3,2,1,3,4,4,3,4]
temp_hunter = [5,3,4,3,3,2,4,5,2]
axis_x = ['0.1','0.2','0.3','0.4','0.5','0.6','0.7','0.8','0.9']
c = (
Line() # 生成line类型图表
.add_xaxis(axis_x) # 添加x轴,Faker.choose()是使用faker的随机数据生成x轴标签
.add_yaxis("捕食者", temp_hunter, is_smooth=True)
.add_yaxis("猎物", temp_prey, is_smooth=True)
.set_global_opts(title_opts=opts.TitleOpts(title='Line Line'))
.render("line_areastyle_boundary_gap.html")
)
效果如下: