如何在plotly python中编辑xaxis记号

2024-04-26 22:37:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我用plotly express line绘制了一幅图。现在我想编辑x轴刻度,使其成为每个月的第一天,这意味着我将得到1月1日2月1日3月1日4月1日。我如何实现这一点?我在试着用

fig = px.line(df, x='date',y='value',color='transportation')

fig.update_layout(
    xaxis_tickformat = '%d %b',
    xaxis=dict(
                tickmode = 'array',
                tickvals = ['2020-02-01'],
                ticktext = ['1 Feb'])

enter image description here

但滴答声和滴答声不会改变


Tags: 编辑dfdatevaluelinefig绘制update