赞
踩
Python:wordcloud.wordcloud()函数的参数解析及其说明
目录
wordcloud.wordcloud()函数的参数解析及其说明
class WordCloud Found at: wordcloud.wordcloudclass WordCloud(object): | 类WordCloud在:WordCloud找到。wordcloudclass WordCloud(对象): 用于生成和绘制的Word云对象。 参数 ---------- font_path:字符串 要使用的字体(OTF或TTF)的字体路径。 Linux机器上的默认DroidSansMono路径。如果你在另一个操作系统上或者没有这个字体,你需要调整这个路径。 width :int(默认=400) 画布的宽度。 height :int(默认=200) 画布的高度。 prefer_horizontal : float(默认=0.90) 尝试水平拟合与垂直拟合的时间比。如果prefer_horizontal < 1,算法将尝试旋转不适合的单词。(目前还没有内置的方法来只获取垂直的单词。) mask : nd-array或None(默认=None) 如果没有,给出一个二进制掩码在哪里绘制单词。如果遮罩不是None,宽度和高度将被忽略,而使用遮罩的形状。所有白色(#FF或#FFFFFF)的参赛作品将被视为“屏蔽”,而其他参赛作品将可以自由提取。[这在最近的版本中有所改变!] scale :浮动(默认=1) 在计算和绘图之间缩放。对于大的字云图像, 使用scale而不是更大的画布尺寸会快得多,但可能会导致适合文字的粗化。 min_font_size : int(默认=4) 使用的最小字体大小。将停止时,没有更多的空间在这个大小。 font_step : int(默认=1) 字体的步长。font_step > 1可能会加速计算,但是匹配效果更差。 max_words :数字(默认=200) 单词的最大数量。 stopwords :一组字符串或没有 将被删除的单词。如果没有,将使用内置的STOPWORDS列表。 background_color :颜色值(默认=“黑色”) 背景色为字云图像。 max_font_size : int或None(默认=None) 为最大的字的最大字体大小。如果没有,则使用图像的高度。 mode :string(默认="RGB") 当模式为“RGBA”,background_color为None时,将生成透明背景。 relative_scaling :浮动(默认= 5) 字体大小的相对频率的重要性。对于relative_scaling=0,只考虑单词的等级。使用relative_scaling=1,出现频率两倍的单词的大小也会增加一倍。如果您想要考虑单词的频率而不仅仅是它们的排名,那么在5左右的relative_scaling通常看起来不错。 . .versionchanged: 2.0 现在默认值是0.5。 color_func:可调用,默认=无 可调用参数word, font_size, position, orientation, font_path, random_state,为每个单词返回一个PIL颜色。 覆盖“colormap”。请参阅colormap以指定matplotlib的colormap。 regexp :字符串或无(可选) 正则表达式,用于在process_text中将输入文本分割为令牌。 如果没有指定,“r”\ w (\ w) +”“使用。 & collocations :bool, default=True 是否包含两个单词的搭配(双字母组合)。 . .versionadded: 2.0 colormap : string或matplotlib colormap,默认="viridis" Matplotlib colormap为每个单词随机绘制颜色。 如果指定了“color_func”,则忽略。 . .versionadded: 2.0 normalize_plurals : bool, default=True 是否删除单词后面的“s”。如果是真的,并且一个单词出现时带有或不带有结尾s,那么带有结尾s的单词将被删除,并将其计数添加到没有结尾s的版本中——除非这个单词以“ss”结尾。 |
Attributes ---------- ``words_`` : dict of string to float Word tokens with associated frequency. .. versionchanged: 2.0 ``words_`` is now a dictionary ``layout_ `` : list of tuples (string, int, (int, int), int, color)) Encodes the fitted word cloud. Encodes for each word the string, font size, position, orientation and color. Notes ----- Larger canvases with make the code significantly slower. If you need a large word cloud, try a lower canvas size, and set the scale parameter. The algorithm might give more weight to the ranking of the words than their actual frequencies, depending on the ``max_font_size ` and the scaling heuristic. """ | 属性 --------- ' ' words_ ' ':浮动字符串的dict 具有相关频率的单词标记。 . .versionchanged: 2.0 “words_”现在是一本字典 ' ' layout_ ' ':元组列表(字符串,int, (int, int), int, color)) 编码合适的词云。为每个单词编码字符串、字体大小、位置、方向和颜色。 笔记 ----- 较大的画布使代码明显地变慢。如果你需要一个大的字云,尝试一个较低的画布大小,并设置比例参数。 根据' ' max_font_size '和缩放启发式,算法可能给予单词的排名比它们的实际频率更多的权重。 ”“” |
def __init__(self, font_path=None, width=400, height=200, Alias to generate_from_frequencies. Parameters Returns ---------- max_font_size : int Returns """ Parameters Returns ..versionchanged:: 1.2.2 Notes The input "text" is expected to be a natural text. If you pass a Calls process_text and generate_from_frequencies. ..versionchanged:: 1.2.2 Returns The input "text" is expected to be a natural text. If you pass a Alias to generate_from_text. Calls process_text and generate_from_frequencies. Returns Applying a new coloring is much faster than generating the Parameters color_func : function or None, default=None colormap : string or matplotlib colormap, default=None Returns Parameters Returns Returns Returns |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。