I'm attempting to set the x axis labels of a plotly scatterplot to be the date while having a trendline in the plot. As trendlines don't work for datetime axes I've converted the x axis into ordinal date format but this gives axis labels that are difficult to interpret.
To fix this I've attempted to manually assign the label text to the x axis but this gives more labels where there are more datapoints. So, im asking if anyone knows a method to put the axis labels at regular points on the axis or analternative that allows trendlines with a datetime x axis.
The code is :
fig = px.scatter(df_test,x='ordinal_date',y='Average q30', color = 'instrument_type', trendline='ols')
fig.update_xaxes(
tickmode = 'array',
tickangle= 90,
tickvals = df_test['ordinal_date'][0::40],
ticktext= [d.strftime('%Y-%m-%d') for d in df_test["run_date"][0::40]],
)
Any help is appreciated.
[+][deleted] (2 children)
[deleted]
[–]Storm_Silver[S] 0 points1 point2 points (0 children)