如何在matplotlib图形中将点更改为逗号? [英] How to change point to comma in matplotlib graphics?
本文介绍了如何在matplotlib图形中将点更改为逗号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在yticklabel
小数点分隔符上从小数点更改为逗号,但是在使用 .
I want to change on the yticklabel
decimal separator from a decimal point to a comma, but leave the format of the offset text (1e-14), after using code from this code or that code.
我的问题:
- 如何将点更改为逗号并保存1e-14?
- 如何在偏移文本中将
e
更改为E
?
- How can I change the point to a comma and save 1e-14?
- How can I change
e
toE
in the offset text?
我正在使用Python 3.5
I am using Python 3.5
推荐答案
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()
将偏移量文本中的指数更改为E
似乎不是一个简单的任务.您可能会在此处.
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.
这篇关于如何在matplotlib图形中将点更改为逗号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文