Python 단순 실현 어 클 라 우 드 코드 및 절차 분석

wordcloud 설치

pip install wordcloud
2.가방 을 불 러 오고 경 로 를 설정 합 니 다.

import os
from wordcloud import WordCloud
import matplotlib.pyplot as plt
os.chdir('E:\\pyspace\\tmp')
3.단어 구름 그림 예제
1.기본 매개 변수 예제

text = 'Keep it simple and stupid.'
wc = WordCloud() #         
wc.generate(text) #          
plt.imshow(wc) #      

주 피 터 에 그래 픽 출력 이 없 으 면 주 피 터 의 그래 픽 디 스 플레이 방식 을 설정 해 야 합 니 다.%matplotlib inlineWordCloud()단어 구름 그림 대상 에 대응 하 는 캔버스 는 기본 길이 200 픽 셀,너비 400 픽 셀,배경 색 은 검은색 입 니 다.
2.설정 매개 변수 예제

text = 'Keep it simple and stupid.'
wc = WordCloud(background_color='white', width=500, height=300) #         

wc.generate(text) #          
plt.imshow(wc) #      

3.좌표 축 보이 지 않 음

text = 'Keep it simple and stupid.'
wc = WordCloud(background_color='white', width=500, height=300) #         

wc.generate(text) #          
plt.imshow(wc) #      
plt.axis('off') #       
plt.show()

환경 설명:

이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기