WordCloud概述GitHub
github:https://github.com/a mueller/word _ cloud
example:https://github.com/a mueller/word _ cloud/tree/master/examples
什么是wordcloud?
在说wordcloud之前,我们必须理解名词。 什么是语云图呢?
云图又称文字云,是文本中出现频率较高的“关键词”的可视化表示,云图过滤出大量低频低质量的文本信息,让阡陌浏览者一眼扫描文本就能了解文本的主旨。
WordCloud WordCloud是python环境中的字云工具包,同时支持python2和python3,可以将关键字数据以代码形式转换为直观有趣的字符模式。
安装
pip默认安装方式
pipinstallwordcloud http://www.Sina.com /
conda install-cc onda-forgewordcloud http://www.Sina.com /
1、首先检查自己使用的python是哪个版本的
python --versionPython 3.7.1 2、打开非正式第三方whl文件包的网站https://www.lfd.UCI.edu/~ Goh lke/python libs /,安装支持的版本这是python3.7的wython
3、下载结束后打开cmd,用pip安装wheel执行命令
pip install wheel 4,cmd切换到刚才下载的word cloud-1.5.0-cp37-cp37m-win _ amd64.whl目录,然后运行命令
pipinstallwordcloud-1.5.0-cp37-cp37m-win _ amd64.whl
如图所示,证明安装成功
使用方法
简单的实例解说:
withopen(tmp/tag.txt (,encoding=) utf-8 ) ) as file: #数据文件txt=file.read ) #如果数据文件包含中文,则为font 这里不需要重复数据,所以设定为False # width幕布的宽度。 height幕布高度# max_words要显示的最大单词数# generate读取文本文件word cloud=word cloud (font _ path=' c :/windows/fonts/ssts ) 生成width=800,height=600,max_words=100 ).generate(txt )图像image=wordcloud .
如果是使用conda的方式安装,则使用以下命令安装
wordcloud输入第三方安装包,也可以下载whl文件到本地然后本地安装
3359 github.com/a mueller/word _ cloud/blob/master/examples/a _ new _ hope.py
参数说明
http://www.Sina.com/http://www.Sina.com/https://www.Yu que.com/Darren-IRB ls/python/pr2zc 5
更多官方示例讲解
详细参数讲解请查看
font_path
斯汀
字体路径windows:c :/windows/fonts/Linux :/usr/share/fontswidthint (default=400 ) )输出的画布宽度为, 缺省为400像素heightint ) ) default ) ) 400像素。缺省为200像素prefer _ horizontal float (default=0. 90 )字水平排版的出现频率,缺省为
如果参数为空,则使用二维蒙版绘制单词组。 如果mask不为空,则会忽略设置的宽度和高度值。 遮罩形状将替换为mask,并按比例放大画布,以便scalefloat=1(default=1)。 例如,如果设定为1.5,则长度和宽度是原始画布的1.5倍的min_font_sizeint(default=4)所示的最小字体大小font _ stepint (default=1)字体max_wordsnumber(default=200 )要显示的最大单词数将stopwords set of strings or None设置为需要屏蔽的单词,如果为空,则设置内置stop words background _ colord
显示的最大字体大小modestring(default=“RGB”)。 如果参数为“RGBA”且background_color不为空,则背景为透明relative _ scaling float (default=.5 )。default=None此函数用于生成新颜色。 如果为空,请使用self.color _ funcregexpstringornone (optional )
输入的文本collocations bool由正则表达式分隔,default=True中是否包含colormapstringormatplotlibcolormapdefault=" viridis "这两个单词
如果为每个单词随机分配颜色并指定color_func,random_state int or None将为每个单词返回PIL颜色的在线字云工具,而忽略此方法
https://wordart.com/
属性
http://www.picdata.cn/indexb.php
数据类型|默认值
3359 worditout.com/word-cloud/create
转载于:https://www.cn blogs.com/jesn/p/10312706.html