python筆記:5.3.18_基本統計圖形_詞雲圖

 

# -*- coding: utf-8 -*-
"""
Created on Mon Jun 10 07:52:16 2019

@author: User
"""

import jieba
from wordcloud import WordCloud
import pandas as pd
import matplotlib.pyplot as plt

s=pd.read_csv('data\\ch5\zhuxian.csv',encoding = "utf-8")
#print(s.head())
print(s.info())

mylist=s['chapter1']
word_list=[" ".join(jieba.cut(sentence)) for sentence in mylist]
new_text=' '.join(word_list) # 將所有文本鏈接起來
wordcloud=WordCloud(font_path='c:\\windows\\font\\msyh.ttc', # 'data\\ch5\msyh.ttc'
                    background_color="white",
                    width=4000,
                    height=2000,
                    max_words=200).generate(new_text)
plt.imshow(wordcloud)
plt.axis('off')
plt.show()

運行:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章