1

I want my y-axis to be more readable so would like a comma separator for thousands. For example, "12000000" should look like "12,000,000"

My dataframe contains the year, country and passengers per year data for air travel in 3 countries.

Jupyter Notebook code:

    sns.relplot(x='year',y='passengers',data=air_travel,kind='line',hue='country')
plt.ticklabel_format(style='plain',axis='y',useOffset=True)

Output plot

Bandit King
  • 183
  • 10
  • 3
    Does this answer your question? [How to format seaborn/matplotlib axis tick labels from number to thousands or Millions? (125,436 to 125.4K)](https://stackoverflow.com/questions/53747298/how-to-format-seaborn-matplotlib-axis-tick-labels-from-number-to-thousands-or-mi) – Bernardo stearns reisen Apr 13 '20 at 21:43
  • This example is for the xaxis, so just use the yaxis commands instead. – Trenton McKinney Apr 13 '20 at 21:45
  • 1
    `ax.yaxis.set_major_formatter(matplotlib.ticker.StrMethodFormatter('{x:,.0f}'))`. The answer in the linked question has something slightly more complicated as an addition in its last lines. The benefit is that it keeps working when values change. – JohanC Apr 13 '20 at 21:49
  • See [this post](https://stackoverflow.com/questions/25973581/how-do-i-format-axis-number-format-to-thousands-with-a-comma-in-matplotlib/46574866#46574866) – JohanC Apr 13 '20 at 21:55

0 Answers0