# -*- 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()
運行: