I've been trying to plot grouped data and so far all goes well. However, I plot along the X axis with Hebrew text and it comes out Left-To-Right instead of Right-To-Left which makes it really unreadable. Here is an example plot I did:
The text I wanna convert from LTR to RTL is marked with a red circle
Basically, I group the data by columns [x,y] for example, and matplotlib plots according to those column names, as desired. But I want to know if there is a way to turn the test as desired to RTL. Here is some code to show how I group the data and plot it:
def plot_grouped_data(DataFrame, columns, n_first, ascending = True):
if(ascending):
Grouped_data = DataFrame.groupby(by = columns).Price.sum().nlargest(n = n_first)
else:
Grouped_data = DataFrame.groupby(by = columns).Price.sum().nsmallest(n = n_first)
Grouped_data.plot(kind = "bar", figsize = (23, 8), fontsize = 14)
plt.ylabel("Sum of car price", fontsize = 16)
plt.show()
I've been trying to find an answer for this online, yet found none. Is there a way to flip the test as desired?
Maybe this answer comes a bit late, but for anyone looking for a solution to this problem: try switching the strings to rtl using "string"[::-1] as per Leonid Nikolaev's answer here.