Scatter Plot Graph with Arabic Text-labelled Data points

import matplotlib.pyplot as plt
from bidi.algorithm import get_display
import arabic_reshaper
import numpy as np
# plot function
def plotnow(words):  
    word_vectors = np.vstack([model[w] for w in words])
    word_vectors.shape   
    from sklearn.decomposition import PCA
    twodim = PCA().fit_transform(word_vectors)[:,:2]
    twodim.shape  
    fig, ax = plt.subplots(1, figsize=(10, 6))
    fig.suptitle('Arabic Example Of Labelled Scatterpoints')
    # Plot the scatter points
    ax.scatter(twodim[:,0], twodim[:,1],
     color="red", # Color of the dots
     s=100, # Size of the dots
     alpha=0.5, # Alpha of the dots
     linewidths=1) # Size of edge around the dots

    for word, (x_pos,y_pos) in zip(words, twodim):
        xword = arabic_reshaper.reshape(word) # support arabic letters
        artext = get_display(xword) 
        ax.annotate(artext, # The label for point
        xy=(x_pos, y_pos), # Position of the corresponding point
        xytext=(7, 0), # Offset text by 7 points to the right
        textcoords='offset points', # tell it to use offset points
        ha='left', # Horizontally aligned to the left
        va='center') # Vertical alignment is centered
        # Show the plot
        plt.show()
from gensim.models import word2vec
sentences = [
    'تفتح التجارب الأولية لفحص جديد لفيروس كورونا الطريق أمام إمكانية تشخيص الفيروس خلال ثوان بدلا من ساعات.',
    'وأظهرت الأبحاث أن الفحص عن طريق التنفس، وهو أسلوب طور في مقاطعة ويلز، قد يكون قادرا عن التمييز بين فيروس كورونا وأي عدوى صدرية أخرى في الحال تقريبا.',
    'وجاء نشر البحث في دورية ذا لانسيت بعد إجراء تجارب في ألمانيا واسكتلندا.',
    'وقال المطورون (إيمسبيكس دياغنوستيكس) إن أجهزة الفحص قد تكون جاهزة للاستعمال خلال ستة شهور، إذا حصلوا على التمويل اللازم.'
]

for i, sentence in enumerate(sentences):
	tokenized= []
	for word in sentence.split(' '):
		word = word.split('.')[0]
		word = word.lower()
		tokenized.append(word)
	sentences[i] = tokenized

model = word2vec.Word2Vec(sentences, workers = 1, size = 200, min_count = 1, window = 2, sg = 0)

listofwords =  model.wv.vocab.keys()
plotnow(listofwords)


14 thoughts on “Scatter Plot Graph with Arabic Text-labelled Data points

  1. Greate article. Keep posting such kind of information on your page.

    Im really impressed by your blog.
    Hey there, You’ve performed a great job.
    I’ll definitely digg it and personally suggest to my friends.
    I am confident they’ll be benefited from this site.

  2. I needed to thank you for this great read!!
    I definitely loved every little bit of it. I’ve got
    you bookmarked to check out new things you post…

  3. Thanks for your article on the vacation industry. I’d also like to include that if you’re a senior considering traveling, it is absolutely imperative that you buy travel cover for senior citizens. When traveling, older persons are at greatest risk of experiencing a medical emergency. Obtaining right insurance cover package in your age group can safeguard your health and provide peace of mind.

  4. You could certainly see your skills in the work you write. The world hopes for even more passionate writers like you who are not afraid to say how they believe. Always follow your heart.

  5. We are a group of volunteers and starting a new scheme in our community. Your web site provided us with valuable info to work on. You have done a formidable job and our entire community will be grateful to you.

  6. Hey there just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same outcome.

  7. It’s perfect time to make some plans for the future and it is time to be happy. I have read this post and if I could I want to suggest you few interesting things or advice. Maybe you can write next articles referring to this article. I wish to read more things about it!

  8. I抎 have to examine with you here. Which is not one thing I usually do! I get pleasure from studying a submit that will make individuals think. Also, thanks for allowing me to comment!

  9. great publish, very informative. I ponder why the opposite specialists of this sector do not notice this. You must proceed your writing. I am sure, you’ve a great readers’ base already!

  10. Hey there, You have performed a fantastic job. I will certainly digg it and in my opinion suggest to my friends. I’m sure they’ll be benefited from this site.

  11. Thanks for your post right here. One thing I would really like to say is that often most professional areas consider the Bachelor Degree like thejust like the entry level requirement for an online certification. While Associate College diplomas are a great way to begin with, completing your current Bachelors opens up many doorways to various employment goodies, there are numerous internet Bachelor Diploma Programs available through institutions like The University of Phoenix, Intercontinental University Online and Kaplan. Another thing is that many brick and mortar institutions offer you Online types of their qualifications but normally for a extensively higher charge than the providers that specialize in online degree plans.

  12. My brother recommended I would possibly like this web site. He used to be entirely right. This post actually made my day. You can not imagine just how so much time I had spent for this information! Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Rits Blog by Crimson Themes.