Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
keeleliin
word_cloud_est
Commits
db0a057f
Commit
db0a057f
authored
Sep 22, 2014
by
Andreas Mueller
Browse files
add max font size argument
parent
031449e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
wordcloud/wordcloud.py
View file @
db0a057f
...
...
@@ -64,6 +64,10 @@ class WordCloud(object):
background_color : color value (default="black")
Background color for the word cloud image.
max_font_size : int or None (default=None)
Maximum font size for the largest word. If None, height of the image is
used.
Attributes
----------
words_ : list of tuples (string, float)
...
...
@@ -77,7 +81,7 @@ class WordCloud(object):
def
__init__
(
self
,
font_path
=
None
,
width
=
400
,
height
=
200
,
margin
=
5
,
ranks_only
=
False
,
prefer_horizontal
=
0.9
,
mask
=
None
,
scale
=
1
,
color_func
=
random_color_func
,
max_words
=
200
,
stopwords
=
None
,
random_state
=
None
,
background_color
=
'black'
):
random_state
=
None
,
background_color
=
'black'
,
max_font_size
=
None
):
if
stopwords
is
None
:
stopwords
=
STOPWORDS
if
font_path
is
None
:
...
...
@@ -97,6 +101,9 @@ class WordCloud(object):
random_state
=
Random
(
random_state
)
self
.
random_state
=
random_state
self
.
background_color
=
background_color
if
max_font_size
is
None
:
max_font_size
=
height
self
.
max_font_size
=
max_font_size
def
_fit_words
(
self
,
words
):
"""Generate the positions for words.
...
...
@@ -146,8 +153,7 @@ class WordCloud(object):
img_array
=
np
.
asarray
(
img_grey
)
font_sizes
,
positions
,
orientations
,
colors
=
[],
[],
[],
[]
# intitiallize font size "large enough"
font_size
=
height
font_size
=
self
.
max_font_size
# start drawing grey image
for
word
,
count
in
words
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment