Date Formatting fro x axis ticks

Hi team,

I am trying to format the x axis date ticks. I want to show the First tick and the Last tick and show ticks for every 7 days.
How I do that?
Here is my code:

fig.update_xaxes(
showgrid=True,
ticks=“inside”,
tickson=“boundaries”,
ticklen=5,
tick0=df1[‘Date’][0],
dtick=7,
tickmode=‘auto’,
tickformat= ‘%d %b’
#dtick=4
#nticks=4
)

Thanks,
E

@vgelis

dtick=7 is not the right setting, but this one:

fig.update_layout(xaxis_tick0 = df1['date'][0], xaxis_dtick=86400000*7)

Why dtick= 86400000*7? We get the answer from the help on dtick property of XAxis or YAxis:
help(go.layout.XAxis.dtick):

If the axis `type` is "date", then you must convert the
    time to milliseconds. For example, to set the interval between
    ticks to one day, set `dtick` to 86400000.0. "date" also has
    special values "M<n>" gives ticks spaced by a number of months.
    `n` must be a positive integer. To set ticks on the 15th of
    every third month, set `tick0` to "2000-01-15" and `dtick` to
    "M3". To set ticks every 4 years, set `dtick` to "M48"
1 Like

Awesome! Thank you so much!