0

so there's a problem with displaying persian letters in my plot here that they seem to break, i solved the problem of left-to-right with adding [::-1] that someone mentioned in a forum but the letters are now in the right alignment (right-to1-left) yet they're separated, how can i fix them???? i've uploaded a picture of how the problem occurs

p.s. all the other entries here pointed at single senteces to be fixed by arabic_reshaper or some other libraries but ive used data from cells above in jupyternotebook. please help me!!

picture

sankopay
  • 11
  • 4

2 Answers2

0

You imported the reshape method from arabic_reshaper but you didn't use that. use it! You can use it for multiple inputs, one input at a time (in the loop) Take a look at this link

  • i’ve imported it as suggested in the exact link that you’ve posted because i’ve reviewed it all, but in all cases there was this limited input like اللغه العربيه but mine is a set of words to be adjusted and reshaped thats why the library is untouched... i dont know how to put it to work for all my cluster_names and set of words ... there was a problem with the rtl alignment and i managed to solve it with a help of someone saying you should add [::1] after your string and that solved it, why cant reshape happen without any loops or one at a time input? – sankopay Jan 17 '21 at 07:43
  • I mean you have a for loop in the last line of your code. use `reshape(df.iloc[i]['title'])` instead And if u did it before, maybe u should search more for rtl alignment in matplotlib. – Mohammad Talaei Jan 17 '21 at 10:25
  • so I think maybe encoding your Persian words before importing them in python would be helpful. you can use Notpad++, encode your text and copy it to another file and save it. there is an Arabic encoding there. – Mohammad Talaei Jan 18 '21 at 12:59
0

To use arabic in Jupyter notebook, yes you have to use the reshape method on the required text and then also use:

import arabic_reshaper
from bidi.algorithm import get_display


reshaped_text = arabic_reshaper.reshape(arabic_text)
bidi_text = get_display(reshaped_text)
plt.title(bidi_text)

this worked with me

enter image description here