python画统计图代码_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()

  • 6
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值