2

I'm trying to show a Barchart which will show the frequency of each character in Bangla Language in a particular text. But it shows empty box in horizontal positions.

def GTStat():
    charFreq = {'ক': 30041, 'খ': 22981, 'র': 20806, 'ট': 19265, 'প': 16943, 'ন': 15478, 'ত': 13840}
    plt.bar(range(len(charFreq)), list(charFreq.values()), align='center')
    plt.xticks(range(len(charFreq)), list(charFreq.keys()))
    plt.show()

But it shows empty box instead of characters enter image description here

Shahrear Bin Amin
  • 1,075
  • 13
  • 31

1 Answers1

-1

You can specify a font that supports your language like this:

def GTStat():
    charFreq = {'ক': 30041, 'খ': 22981, 'র': 20806, 'ট': 19265, 'প': 16943, 'ন': 15478, 'ত': 13840}
    plt.bar(range(len(charFreq)), list(charFreq.values()), align='center')
    plt.xticks(range(len(charFreq)), list(charFreq.keys()), name="Nikosh")
    plt.show()

Where you should place a font family name instead of Nikosh in code above.

If you are getting findfont: FontFamily not found you can follow instructions in this stackoverflow answer

Erfan Loghmani
  • 607
  • 4
  • 7