加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

如何在python中更改轴上逗号的点

发布时间:2020-12-17 17:38:23 所属栏目:Python 来源:网络整理
导读:我添加到我的代码 import localelocale.setlocale(locale.LC_NUMERIC,"de_DE")plt.rcParams['axes.formatter.use_locale'] = Trueimport matplotlib.pyplot as pltimport numpy as np 并且它在区域设置中不起作用.错误:不支持的区域设置 我测试过Wheater,我

我添加到我的代码

import locale
locale.setlocale(locale.LC_NUMERIC,"de_DE")

plt.rcParams['axes.formatter.use_locale'] = True
import matplotlib.pyplot as plt
import numpy as np

并且它在区域设置中不起作用.错误:不支持的区域设置

我测试过Wheater,我在语言环境-a中列出了de_DE,但我没有:

cs_CZ.utf8
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
id_ID.utf8
POSIX

这里也是其中一些的默认逗号吗?我以为是CZ,但是还没有.所以我尝试安装de_DE

cd /usr/share/locales
./install-language-pack de_DE

但是,结果是

sed: do?asny soubor /etc/sed8Oob4Q nelze otev?ít: Operace zamítnuta

这意味着该操作是
被拒绝.

写而不是locale.setlocale(locale.LC_ALL,’de_DE’)locale.setlocale(locale.LC_ALL,’de_DE.utf8′)效果不佳.

我试图在终点站跑

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

是否可以通过使用另一种语言来选择像默认语言一样的de_DE?

然后,我使用export LC_ALL = C,什么也没发生.您还有其他想法要设置在matplotlib逗号中而不是轴上吗?谢谢

最佳答案
您输入的代码不正确,请在加载matplotlib之前调用plt.rcParams.

这段代码可以正常工作:

import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['axes.formatter.use_locale'] = True
import locale

print(locale.getlocale()) # default locale,have to be None 
locale.setlocale(locale.LC_NUMERIC,"de") # 'de' for Win or 'de_DE' for linux/mac
print(locale.getlocale()) # test locale after setup
fig,axis = plt.subplots(2,2)  
plt.show()

enter image description here

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读