X, Y axis label alignment


I am new to plotly and following examples listed at:

One thing I observed here is, X-axis labels are

  1. not aligned
  2. Don’t show actual data from the series like year 1952.

How do I change the call to show that?

Thanks in advance!

Hi @ncsuchess
What do you mean the x-axis labels are not aligned? And it seems that they do start from 1952. It just doesnt say 1952 because the x-axis text starts from 1960

Hi @adamschroeder

Thanks for the response.

For example, in the first bar graph, the X-range is 1950-2007. If I understand correctly this was chosen with auto-scaling. Instead of this, I would like to see actual numbers of bars like 1952, 1957, 1962, etc positioned at the center of the bar. How does one do it? Without this, I really can’t see the value unless I hover over it.

Now I understand what you mean. Just add this to the script:

fig.update_layout(xaxis={'tickmode':'array', 'tickvals':[1952,1957,

This worked for me. And here’s where I found the info.

I’m actually going to publish a tutorial all about the bar chart this weekend, which should cover more layout features. For now, feel free to see other tutorials here if you’re interested.


Thank you so much! This worked for me as well.

I am glad that you are thinking of doing a tutorial. Just a suggestion about that.

It would immensely help if you can start with default options and show how the chart looks like similar to the examples above. Then you can progressively add one option at a time to show how things change for better.

Given a multitude of ways of configuring any chart, it gets very confusing. So tutorial like that would immensely help!

Thanks again!

1 Like