python读取读取excel某列内容制作词云图并用条形图统计词频某列内容制作词云图并用条形图统计词频
有的时候我们把数据整理收集整理到excel中,那么要把excel中的某列文本数据制作词云图怎么做呢?
从最简单的说起。
最简单的词云图就是这种,英文的,不读取文件,不指定背景形状图片,不指定字体。
#复制文本用字符串表示
mytext = "With his wife's encouragement, Minister Hacker decides he should focus on accomplishing 1 or 2 significant achievements while in office. He
decides the time has come to promote more women into the senior ranks of the civil service. Needless to say, Sir Humphrey very much wants to maintain
the status quo and arranges for his fellow permanent secretaries to brief their own Ministers accordingly. Hacker nonetheless insists on promoting a
woman in his own department, but things don't quite work out as planned.With his wife's encouragement, Minister Hacker decides he should focus on
accomplishing 1 or 2 significant achievements while in office. He decides the time has come to promote more women into the senior ranks of the civil
service. Needless to say, Sir Humphrey very much wants to maintain the status quo and arranges for his fellow permanent secretaries to brief their own
Ministers accordingly. Hacker nonetheless insists on promoting a woman in his own department, but things don't quite work out as planned."
from wordcloud import WordCloud #导入wordcloud包
import matplotlib.pyplot as plt
#print(mytext)
wordcloud = WordCloud(background_color="white",max_words=100) #指定词云背景色为白色,最大词数为100个单词
wordcloud.generate(mytext) #生成词云
plt.imshow(wordcloud,interpolation='bilinear') #显示词云图
plt.axis("off") #关闭词云图坐标轴
plt.show()
原创文章 2获赞 1访问量 110
关注
私信
展开阅读全文
作者:墨 tsui
评论1
最新资源