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

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

作者: 吴强_71b2 | 来源:发表于2017-11-01 22:09 被阅读0次

代码:

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()

结果:

相关文章

网友评论

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

      本文链接:https://www.haomeiwen.com/subject/mgrnpxtx.html