Displaying Unicode characters like করে in matplotlib
1 answer
Python3
This should work with a font that contains these Unicode characters. I used kalpurush to cover Unicodes Bangla. You can pass the font in the matplotlib
following way:
import matplotlib.font_manager as fm
import matplotlib.pyplot as plt
prop = fm.FontProperties(fname='kalpurush.ttf')
s = u"কৃষক জমিতে ধান চাষ করে"
x = 0.2
y = 0.2
plt.text(x, y, s, fontproperties=prop)
plt.show()
Bonus: Python2
For python 2, this is very easy. just add this to the top of the file:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+2
source to share