I want to plot the text, "কৃষক জমিতে ধান চাষ করে", with matplotlib, what to do...?
I tried the flowing, but it didn't work.
s = u"কৃষক জমিতে ধান চাষ করে"
x = 0.2
y = 0.2
matplotlib.pyplot.text(x, y, s)
This should work with a font that contains these unicode characters. I used kalpurush to cover the Bangla unicodes. You can pass the font to matplotlib
like this:
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()
For python 2 this is super easy. just add this at the top of the file:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With