开发者

plotly express shows mid of the day marks that are not in the dataframe, how to fix?

how not to show mid of the 12pm on the chard. I want days only. Here is the dataset from the chart https://easyupload.io/gxfiq1

df_combined = df_combined.sort_values(by='s开发者_开发百科old_date', ascending=True)
df_smt = df_combined.loc[df_combined['model'] == 'Adapt'].groupby('date').agg({'price': 'sum', 'sold_date': 'count'}).reset_index()
fig = px.line(df_smt, x='date', y='price', title='Adapt')
fig.show()

plotly express shows mid of the day marks that are not in the dataframe, how to fix?


Looks like you are trying to update the "x-tick" labels. The plotly documentation has some information on how to do this (https://plotly.com/python/tick-formatting/)

Something like

fig.update_layout(
   xaxis_tickformat = '%b %d %Y',
)

should format the x-ticks as month (%b), day (%d), year (%Y).

You can see more information on formatting options here (https://github.com/d3/d3-time-format/blob/main/README.md)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜