Adjusting space between ticks

Thank you for solving a problem I have been banging my head against on and off for over a year. I originally asked the
question here:

How to fix ugly tick spacing on line chart with small data set.

And never got a satisfactory answer- I tried randomly searching again tonight and came across your post, which finally solved my problem!

This code (where data[β€œYear”] is a pd.Series of years in format YYYY:

fig.update_layout(
    xaxis=dict(
        tickvals=data["Year"],
        autorange=False,
        range=[0, len(data["Year"]) - 1],
        tick0=0,
        dtick=1
    ),
)

Gave me exactly what I was looking for, evenly spaced x-axis ticks starting at the left edge and ending at the right edge.

Thank you!