Python 十九大报告报告排名前五词频统计及条状图显示

2017-11-01  本文已影响0人  吴强_71b2

代码:

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十九大报告词频统计',fontproperties=myfont,fontsize=14)

plt.xticks(range(0,5),['社会主义','坚持','发展','人民','建设'],fontproperties=myfont,fontsize=14)

plt.show()

t.head()

结果:

上一篇 下一篇

猜你喜欢

热点阅读