0

I've made a bar chart in matplotlib. In that chart I managed to change the formatting of the number on the y-axes. The only problem is that the thousand seperator is now a comma (','). Since I live in The Netherlands I would very much like to convert that to a dot ('.'). It looks like a simple thing but I can't find anywhere how to do it. Please see code below.

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline

top = [72000, 73000, 78000, 71000]
base = [15000, 12000, 13000, 14000]

x = ['2017', '2018', '2019', '2020']
x_ax = pd.Series(x)

fig, ax = plt.subplots()
ax.bar(x, top, label='TOP CUSTOMERS')
ax.bar(x, base, bottom=top, label='BASE CUSTOMERS')
ax.set_title('TON YTD JULY')
ax.legend(loc='lower center')
ax.set_ylabel('Ton')
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
plt.savefig('C:/Users/MBRU/Box Sync/Data_Source/out/320/example.png', bbox_inches='tight')
plt.show()

Example of graph with code

  • https://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators – JohanC Aug 13 '20 at 13:11
  • Does this answer your question? [Formatting tick label for the German language, i.e., with a point as a thousands separator and comma as a decimal separator](https://stackoverflow.com/questions/60211960/formatting-tick-label-for-the-german-language-i-e-with-a-point-as-a-thousands) – JohanC Aug 13 '20 at 13:12

0 Answers0