I am trying to display plots but the labels are in utf-8 Arabic
, python2.7
.
import matplotlib.pyplot as plt
labels = ['عشرة','عشرين','ثلاثين']
#labels=['A','B','C']
x = [10, 12,13]
y = [10,20,30]
plt.figure(figsize=(16, 16))
for i in range(len(x)):
plt.scatter(x[i],y[i])
plt.annotate(labels[i],
xy=(x[i], y[i]),
xytext=(5, 2),
textcoords='offset points',
ha='right',
va='bottom')
plt.show()
for the utf-8 (labels = ['عشرة','عشرين','ثلاثين']) I have error
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd8 in position 0: ordinal not in range(128)
while it works fine when labels=['A','B','C'].