问题
I want to plot a dataframe
in which the index
consists of datetime
values based on Iranian calendar.
I want to set the x-axis
labels as following:
import matplotlib.dates as mdates
axes.scatter(df_day.index.values, df_day.loc[:, item], marker='.')
axes.xaxis.set_major_formatter(dates.DateFormatter('%d-%b %H:%M'))
Consider that I want to print the months's name in Persian instead of default value of Georgian
calendar such as Jun
or Aug
.
I used jdatetime to convert the datetime
in persian calendar but the plot
function doesn't take it's value as x-axis
index. then I used jalaali to create a datetime
based on persian calendar that plot accepts it.
now the problem is how to print x-axis
label as Persian month names? because I want this format:
dates.DateFormatter('%d-%b %H:%M')
Is there any way of doing that?
UPDATE
I used locale to access to the POSIX locale database and functionality as following:
import locale
locale.setlocale(locale.LC_ALL, 'fa_IR')
but it only changed the name of Georgian
months from English
alphabet in Persian
alphabet instead of showing jalali
names such as فروردین
or اردیبهشت
.
any clue is appreciated.
来源:https://stackoverflow.com/questions/63356748/is-there-a-way-to-show-persian-date-in-x-axis-of-matplotlib-plot