0

I have changed my locale to adapt a matplotlib plot as described in this answer because I want to format the DateTimeIndex within a pandas (matplotlib) plot but it doesn't show any effect.

import locale
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt


locale.setlocale(locale.LC_ALL, 'en_GB.utf8')

data = np.random.randint(low=0, high=10, size=(8760, 2))
index = pd.date_range('2018-01-01 00:00:00', periods=len(data), freq='h')
df = pd.DataFrame(data, index=index)

df.resample('7d').mean().plot(grid=True)
plt.show()

As one can see in the following plot, the formatting of the DateTimeIndex is still in German although I have adapted my locale.

enter image description here

How can I adapt the plot to have another languages date format e.g. [...,"Mar",...,"Dec"] for an English format?

My operating system is Ubuntu Linux 16.04 and the language settings are already set to English.

Thanks in advance!

Cord Kaldemeyer
  • 6,405
  • 8
  • 51
  • 81
  • check the 'uselocale' https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.ticklabel_format.html – Yuca Jul 20 '18 at 16:04
  • `plt.rcParams['axes.formatter.use_locale'] = True` after setting the locale (and changing my system language to EN) does not show any effect. – Cord Kaldemeyer Jul 23 '18 at 07:53

0 Answers0