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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值