pyecharts画图求助:请问我想横坐标显示日期,应该怎么实现呢?

请问我想横坐标显示日期,去掉序号标签,应该怎么实现呢?

pyecharts画图求助:请问我想横坐标显示日期,应该怎么实现呢?
以下代码:

line1=(

Line()

.add_xaxis(df.index.to_list())

.add_yaxis("mA",df["ma"].to_list(),markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="min")]), yaxis_index=0)

.extend_axis(yaxis=opts.AxisOpts(type_="value",

axistick_opts=opts.AxisTickOpts(is_show=True),

splitline_opts=opts.SplitLineOpts(is_show=True),)) # 双坐标轴 这个必须添加,添加虚线

.set_global_opts(title_opts=opts.TitleOpts(title="光管电压电流走势图")))

line2= (

Line()

.add_xaxis(df.index.to_list())

.add_yaxis("KV",df["kv"].to_list(),markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="min")]), yaxis_index=1,

linestyle_opts=opts.LineStyleOpts())

.set_global_opts(title_opts=opts.TitleOpts(title="光管电压电流走势图")))

line1.overlap(line2)

line1.render("11022219N-3.0.html")

line1.render_notebook()


回答:

df.index = df.index.strftime('%Y-%m-%d')

这行:

line1 = (

Line()

.add_xaxis(df.index.to_list())

.add_yaxis("mA", df["ma"].to_list(),

markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="min")]),

yaxis_index=0)

.extend_axis(

yaxis=opts.AxisOpts(

type_="value",

axistick_opts=opts.AxisTickOpts(is_show=True),

splitline_opts=opts.SplitLineOpts(is_show=True),

)

)

.set_global_opts(

title_opts=opts.TitleOpts(title="光管电压电流走势图"),

xaxis_opts=opts.AxisOpts(type_="category") # 设置x轴为类别轴

)

)

以上是 pyecharts画图求助:请问我想横坐标显示日期,应该怎么实现呢? 的全部内容, 来源链接: utcz.com/p/938637.html

回到顶部