Skip to content

단어 구름

pip 명령어로 설치

pip install wordcloud

wordcloud 모듈을 임포트

from wordcloud import WordCloud

설정

wc = WordCloud(
  font_path='NanumGothic.ttf', # 글꼴 파일이 있을 경우
  background_color='white',    # 배경색
  max_words=100,               # 시각화할 단어 개수
  width=400,                   # 가로 크기
  height=300)                  # 세로 크기

word_count를 사전(dict) 형태로 변환

count_dic = dict(zip(word_count.단어, word_count.빈도))

단어 구름

cloud = wc.fit_words(count_dic)

보기

cloud.to_image()

파일로 저장

cloud.to_file('cloud.png')