赞
踩
我们上一篇文章,用词云展示了词频,这一篇,我们用柱状图,圆饼图,散点图等来显示词频,使其可视化。
- from matplotlib.font_manager import FontProperties
- from collections import Counter
- from pylab import *
-
- mpl.rcParams['font.sans-serif']=['SimHei'] # X 轴可以显示中文
- mpl.rcParams['axes.unicode_minus']= False # X 轴可以显示中文
-
- font = FontProperties(fname='SIMYOU.TTF',size=14)
- f3 = open('commont_philips.txt','r').read()
- nowords = ['x','uj','a','ul', 'p','d', 'v','zg','m','ug','i', 'f', 'ad','nz', 'r', 'r', 'ns','q','t','c']
-
- wods =[x.word for x in psg.cut(f3) if len(x.word)>=2 and (x.flag) not in nowords]
- word_count = Counter(wods)
- print(word_count)
-
- x=[x[0] for x in word_count.most_common(20)] #统计top20个关键字
- y=[x[1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。