目录
- collections词频统计库
- matplotlib图像展示库
- wordcloud词云展示库
collections词频统计库
import collections
word_counts = collections.Counter(one_list)
print(word_counts)
word_counts_top30 = word_counts.most_common(number)
print(word_counts_top30)
matplotlib图像展示库
import matplotlib.pyplot as plt
plt.figure(number, figsize=(8, 8))
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.barh(x, y, tick_label=names, color=color, align='center')
plt.text(x, y, z, ha='center', va='top')
plt.title(title)
plt.savefig(file,dpi)
plt.show()
plt.close(number)
wordcloud词云展示库
word_cloud = wordcloud.WordCloud(
mask=mask,
font_path='C:/Windows/Fonts/simhei.ttf',
max_words=100,
max_font_size=100,
min_font_size=30,
)
word_cloud.generate(data)