English for ticks using matplotlib dates

I am a French native speaker, so my OS interface (GNU / Linux Xubuntu) is in French

Thus, when I draw a time series using Matplotlib with datetimeas X data, the returned graph has months written in French

How can I get these printed dates in another language (usually English)?

+4
source share
2 answers

You can set the desired location / language using the module locale. To get English, try installing localeon en_US.

: bash Ubuntu 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'
+3

tom answer , Ubuntu- : import datetime import locale locale.setlocale(locale.LC_ALL,'en_US.utf8')

bash $ local -a

+2

Source: https://habr.com/ru/post/1610455/


All Articles