代碼:
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import jieba.analyse
from scipy.misc import imread
import matplotlib
matplotlib.style.use('ggplot')
%matplotlib inline
from matplotlib.font_manager import *
myfont =FontProperties(fname='E:\wuqiang\salestool\python\wordcloud\DroidSansFallbackFull.ttf')
import pandas as pd
t = pd.read_table(r'E:\img\wordcloud\wordCount.txt',sep=' ',header=None, usecols = [1,2], names =['word','word_freq'],encoding="GBK")
t.head().plot.bar()
plt.title('2017十九大報(bào)告詞頻統(tǒng)計(jì)',fontproperties=myfont,fontsize=14)
plt.xticks(range(0,5),['社會(huì)主義','堅(jiān)持','發(fā)展','人民','建設(shè)'],fontproperties=myfont,fontsize=14)
plt.show()
t.head()
結(jié)果: