当前位置:   article > 正文

python的wordcloud函数_Python:wordcloud.wordcloud()函数的参数解析及其说明

wordcloud has not been calculated, call generate first.

def __init__(self, font_path=None, width=400, height=200,

margin=2,

ranks_only=None, prefer_horizontal=.9, mask=None, scale=1,

color_func=None, max_words=200, min_font_size=4,

stopwords=None, random_state=None,

background_color='black',

max_font_size=None, font_step=1, mode="RGB",

relative_scaling=.5, regexp=None, collocations=True,

colormap=None, normalize_plurals=True):

if font_path is None:

font_path = FONT_PATH

if color_func is None and colormap is None:

# we need a color map

import matplotlib

version = matplotlib.__version__

if version[0] < "2" and version[2] < "5":

colormap = "hsv"

else:

colormap = "viridis"

self.colormap = colormap

self.collocations = collocations

self.font_path = font_path

self.width = width

self.height = height

self.margin = margin

self.prefer_horizontal = prefer_horizontal

self.mask = mask

self.scale = scale

self.color_func = color_func or colormap_color_func(colormap)

self.max_words = max_words

self.stopwords = stopwords if stopwords is not None else

STOPWORDS

self.min_font_size = min_font_size

self.font_step = font_step

self.regexp = regexp

if isinstance(random_state, int):

random_state = Random(random_state)

self.random_state = random_state

self.background_color = background_color

self.max_font_size = max_font_size

self.mode = mode

if relative_scaling < 0 or relative_scaling > 1:

raise ValueError(

"relative_scaling needs to be "

"between 0 and 1, got %f." %

relative_scaling)

self.relative_scaling = relative_scaling

if ranks_only is not None:

warnings.warn("ranks_only is deprecated and will be

removed as"

" it had no effect. Look into relative_scaling.",

DeprecationWarning)

self.normalize_plurals = normalize_plurals

def fit_words(self, frequencies):

"""Create a word_cloud from words and frequencies.

Alias to generate_from_frequencies.

Parameters

----------

frequencies : dict from string to float

A contains words and associated frequency.

Returns

-------

self

"""

return self.generate_from_frequencies(frequencies)

def generate_from_frequencies(self, frequencies,

max_font_size=None):

"""Create a word_cloud from words and frequencies. Parameters

----------

frequencies : dict from string to float

A contains words and asso

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/531983
推荐阅读
相关标签
  

闽ICP备14008679号