Arabic letters aren't showing correctly in the plot

Viewed 1364

I used all the correct encoding and the software does work but the letters in Arabic aren't connected (most Arabic letters are connected when written next to each other)

This is how the plot shows the image

I used the python Pandas module using the bar chart function

1 Answers

The only way I could get around this is to take all the Arabic words in the pandas column that I need to plot and reshape it with arabic_reshaper, append them to a list and have this list as my x axis:

# reshaping the arabic words to show correctly on matplotlib

import arabic_reshaper
import matplotlib.pyplot as plt
from bidi.algorithm import get_display

x = [ ]

for item in df.column_name.values:
    x.append(get_display(arabic_reshaper.reshape(item)))

Of course you need to install the arabic_reshaper and the bidi.algorithm packages first

Related