pyecharts两个散点图类型相同长度不同的x轴合并为一张散点图
编程小白鼠还希望高人可以在代码上帮我调整。我会非常感谢。
1.最后图上展示效果 c_x轴对应c_y的数据,cc_x轴对应cc_y的数据
2.就像图上展示的那样 一个时间坐标对应一个标注点
from pyecharts import options as opts
from pyecharts.charts import Scatter
time_x =['2020-09-03 01:00:00', '2020-09-03 12:00:00', '2020-09-10 01:00:00', '2020-09-13 03:00:00', '2020-09-21 09:00:00', '2020-09-22 07:00:00', '2020-09-24 22:00:00']
# 共享x轴
c_x = ['2020-09-03 01:00:00', '2020-09-13 03:00:00', '2020-09-21 09:00:00', '2020-09-22 07:00:00', ]
c_y = [[10], [30], [36], [70], ]
cc_x = ['2020-09-03 12:00:00', '2020-09-10 01:00:00', '2020-09-24 22:00:00']
cc_y = [[66], [79], [90], ]
c = (
Scatter(init_opts=opts.InitOpts(height='870px',width='860px'))
.add_xaxis(c_x)
.add_yaxis(
"商家A",
# c_y,
[list(z) for z in zip(c_y, c_x)],
)
.set_global_opts()
)#=========================
cc = (
Scatter()
.add_xaxis(cc_x)
.add_yaxis(
"商家b",
[list(z) for z in zip(cc_y, cc_x)],
)
)
c.overlap(cc)
c.render("hebing_sandiantu.html")