使用matplotlib以英语作为日期刻度的语言 [英] English as language for the dates ticks using matplotlib
本文介绍了使用matplotlib以英语作为日期刻度的语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是说法语的人,所以我的操作系统界面(GNU/Linux Xubuntu)是法语
I'm a French native speaker, so my OS interface (GNU/Linux Xubuntu) is in French
因此,当我使用Matplotlib以datetime
作为X数据绘制时间序列时,返回的图将以法语表示的月份
Thus, when I plot a time series using Matplotlib with datetime
as X data, the returned plot have the months written in French
如何获取其他语言(通常是英语)的印刷日期?
How can I obtain those printed dates in another language (typically English) ?
推荐答案
您可以使用 locale
模块.要获取英语,请尝试将locale
设置为en_US
.
编辑:
在Ubuntu上的bash中,您可能需要使用en_US.utf8
EDIT:
In bash on Ubuntu, you may need to use en_US.utf8
In [1]: import datetime
In [2]: import locale
In [3]: locale.setlocale(locale.LC_ALL,'fr_FR')
Out[3]: 'fr_FR'
In [4]: datetime.datetime(2015,7,1).strftime('%B')
Out[4]: 'juillet'
In [5]: locale.setlocale(locale.LC_ALL,'en_US')
Out[5]: 'en_US'
In [6]: datetime.datetime(2015,7,1).strftime('%B')
Out[6]: 'July'
这篇关于使用matplotlib以英语作为日期刻度的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文