0

I want to plot a word vector of URDU text. When i compile the source code, it executes fairly, but blank boxes appear in the resultant graph instead of Urdu text. I need Urdu text instead of boxes. This is my source code:

import numpy as np
import codecs
la = np.linalg

words = ['امریکی','صدر','خبردار','شمالی کوریا','کے','میزائل','اور','.']
arr = np.array([[0,2,1,0,0,0,0,0],
                [2,0,0,1,0,1,0,0],
                [1,0,0,0,0,0,1,0],
                [0,0,0,1,0,0,0,1],
                [0,1,0,0,0,0,0,1],
                [0,0,1,0,0,0,0,8],
                [0,2,1,0,0,0,0,0],
                [0,0,1,1,1,0,0,0]])
u, s, v = la.svd(arr, full_matrices=False)

import matplotlib.pyplot as plt 
for i in range(len(words)):
    plt.text(u[i,2], u[i,3], words[i])

plt.show()

enter image description here

blubberdiblub
  • 4,085
  • 1
  • 28
  • 30
Wahab
  • 61
  • 2
  • 11
  • 1
    you can set enconding to UTF-8 that will help the Urdu text come as it is. Also have a look at this http://stackoverflow.com/questions/728891/correct-way-to-define-python-source-code-encoding – zachi May 02 '17 at 09:42
  • 1
    @zachi: Many thanks for your prompt reply, i added this "# coding=utf-8" to my script but it also does not work – Wahab May 02 '17 at 09:46
  • @zachi, please check my code, i will be very thankful – Wahab May 02 '17 at 09:59
  • 1
    I am not a python developer! Pls do some trial & error with your code and also debug it to attain your desired output. – zachi May 02 '17 at 10:04

0 Answers0