Ich vermute, dass es etwas tricky ist: Meiner Erinnerung nach muss man einen eigenen Formatter verwenden. Diese Funktion kann dann z. B.
locale verwenden, um die Zahlen komfortabel zu gruppieren.
Code: Alles auswählen
import locale
from matplotlib import pyplot as plt
from matplotlib import ticker
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
def format_xtick(x, pos):
return locale.format_string("%.f", x, grouping=True)
def format_ytick(y, pos):
return locale.format_string("%.1f", y, grouping=True)
fig, ax = plt.subplots()
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_xtick))
ax.yaxis.set_major_formatter(ticker.FuncFormatter(format_ytick))
x=[1000, 2000, 3000, 4000]
y=[1, 2, 3, 2]
plt.plot(x,y)
plt.show()