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

代码:

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 十九大报告报告排名前五词频统计及条状图显示_第1张图片


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

你可能感兴趣的:(Python 十九大报告报告排名前五词频统计及条状图显示)