Skip to main content

Posts

Showing posts from August, 2020

Word Cloud for your Name in Urdu

Word cloud is a nice library for generating fun plots with names. Here is an example I've used to generate the cloud with my name. You need to install python-arabic-reshaper,    word cloud, matplotlib, python-bidi and numpy  libraries to generate the plots. You need to install the font  NotoNaskhArabic-Regular.ttf ( https://github.com/frappe/fonts/blob/master/usr_share_fonts/noto/NotoNaskhArabic-Regular.ttf ). This example is used in macOS. import numpy as np import matplotlib.pyplot as plt from wordcloud import WordCloud from bidi.algorithm import get_display from arabic_reshaper import ArabicReshaper configuration = { "language": "Urdu" } reshaper = ArabicReshaper(configuration=configuration) text = reshaper.reshape("عرفان") text = get_display(text) x, y = np.ogrid[:300, :300] mask = (x - 150) ** 2 + (y - 150) ** 2 > 130 ** 2 mask = 255 * mask.astype(int) wc = WordCloud(background_color="white",font_path='/Users/mirfan/Lib