How to change point to comma in matplotlib graphics?

萝らか妹 提交于 2019-12-01 02:38:33
tmdavison

To change the decimal separator from a point to a comma, you can change the locale to somewhere where a comma is used. For example, here I set it to German:

#Locale settings
import locale
# Set to German locale to get comma decimal separater
locale.setlocale(locale.LC_NUMERIC, "de_DE")

import numpy as np
import matplotlib.pyplot as plt
plt.rcdefaults()

# Tell matplotlib to use the locale we set above
plt.rcParams['axes.formatter.use_locale'] = True

# make the figure and axes
fig,ax = plt.subplots(1)

# Some example data
x=np.arange(100)
y=4e-18*x**2

# plot the data
ax.plot(x,y,'b-')

plt.show()

Changing the exponent to E in the offset text does not seem to be a simple task. You might start by looking at the answers here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!