Home > Back-end >  How can the dates in a plot be written in another language different than english? (I am using matpl
How can the dates in a plot be written in another language different than english? (I am using matpl

Time:05-04

So I´m using matplotlib to plot some data and when I use matplotlib.dates, the dates are written in english, but I want the months to be written in spanish, so I tried to solve this by using:

import locale
locale.setlocale(locale.LC_ALL, 'es-ES.utf8')

However, I get the next Error:

Error: unsupported locale setting

And I don´t really know if using 'locale' actually works for the whole Jupyter enviroment. Does anybody has any suggestion?

Thank you! Best regards.

CodePudding user response:

If your OS is Linux, replace the hyphen/dash character (-) by the underscore (_):

import locale
locale.setlocale(locale.LC_ALL, 'es_ES.utf8')

On Windows, I think you could use:

import locale
locale.setlocale(locale.LC_ALL, 'Spanish_Spain.1252')
  • Related