Excel词云图

#coding=utf-8
#encoding=utf8
import jieba
from jieba.analyse import extract_tags
from scipy.misc import imread
from wordcloud import WordCloud, ImageColorGenerator

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

path_text = r'C:\Users\Administrator\Desktop\classname.txt'
f=open(path_text,mode='r',encoding='utf-8',errors='ignore').read()
# with open (path_text) as f:
cut_text=" ".join(jieba.cut(f))
image=Image.open("E:\python爬虫\photo.png")
graph=np.array(image)
wordcloud=WordCloud(font_path="C:\Windows\Fonts\simhei.ttf",min_font_size=14,stopwords=["excel","Excel","Excel2013","Excel2016","视频教程","应用","教程","实战","技巧","课程","Oeasy","职场","高级","基础","玩转","Office","入门","办公"],background_color="white",mask=graph).generate(cut_text)
image_color=ImageColorGenerator(graph)
wordcloud.recolor(color_func=image_color)
wordcloud.to_file(r'E:\python爬虫\wordcloud.png')
plt.imshow(wordcloud)
plt.axis("off")
plt.show()

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值