728x90

from wordcloud import WordCloud
from konlpy.tag import Twitter
from collections import Counter
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

img = Image.open('C:/jupyter_notebook/image.png') #이미지 오픈
imgArray = np.array(img) # 이미지의 각 셀을 수치로 변환


wc = WordCloud(font_path='C:/Windows/Fonts/malgun.ttf',
    width = 600,
    height = 600,
    background_color="white",
    mask = imgArray,    # 사용하고자 하는 이미지 사용
    max_font_size=200)
cloud = wc.generate_from_frequencies(dict(tags))

 

https://www.topcoder.com/thrive/articles/word-cloud-in-python

728x90

+ Recent posts