词云库 stylecloud

参考:https://mp.weixin.qq.com/s/B23uDxzLUa_45uDh2R9Vlw

 

安装:

pip install stylecloud 即可安装

 

直接调用 txt 文本生成词云:

from stylecloud import gen_stylecloud
gen_stylecloud(file_path='Trump.txt',output_name'1.png')

 

词云形状:

蒙版链接-https://fa5.dashgame.com/#/%E5%9B%BE%E6%A0%87

 

 

可以定期更新,见参考链接

调用狗的蒙版:

stylecloud.gen_stylecloud(text=' '.join(text1), collocations=False,
                          font_path=r'‪C:\Windows\Fonts\msyh.ttc',
                          icon_name='fas fa-dog',
                          size=400,output_name='词云.png')

icon_name 参数,有 fas,far,fab,三种前缀,要哪一种图就用哪一种,比如要调用狗,还需 fa 前缀,其他也一样

 

配色:

from stylecloud import gen_stylecloud


word = jieba.lcut(title_word)
gen_stylecloud(text=' '.join(word), collocations=False,
               palette='tableau.BlueRed_6',
               font_path=r'‪C:\Windows\Fonts\msyh.ttc',
               icon_name='fas fa-building',
               size=400,output_name='../标题词云.png')

palett 参数,取值-https://jiffyclub.github.io/palettable/#finding-palettes,参考链接

 

jupyter notebook 中显示

不需要分词的

from IPython.display import Image 
import stylecloud

stylecloud.gen_stylecloud(
    text=name,
    collocations=False,
    font_path=r'‪C:\Windows\Fonts\msyh.ttc',
    icon_name='fas fa-tv',
    size=768,
    output_name='节目名称词云图.png'
)

Image(filename='节目名称词云图.png')

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值