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
b35ed472
Commit
b35ed472
authored
Aug 24, 2015
by
Andreas Mueller
Browse files
add the "pil way" of showing an image to the simple.py
parent
ea578eb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/simple.py
View file @
b35ed472
...
...
@@ -6,15 +6,19 @@ Generating a square wordcloud from the US constitution using default arguments.
"""
from
os
import
path
import
matplotlib.pyplot
as
plt
from
wordcloud
import
WordCloud
d
=
path
.
dirname
(
__file__
)
# Read the whole text.
text
=
open
(
path
.
join
(
d
,
'constitution.txt'
)).
read
()
# Generate a word cloud image
wordcloud
=
WordCloud
().
generate
(
text
)
# Open a plot of the generated image.
# Display the generated image:
# the matplotlib way:
import
matplotlib.pyplot
as
plt
plt
.
imshow
(
wordcloud
)
plt
.
axis
(
"off"
)
...
...
@@ -24,3 +28,7 @@ plt.figure()
plt
.
imshow
(
wordcloud
)
plt
.
axis
(
"off"
)
plt
.
show
()
# The pil way (if you don't have matplotlib)
#image = wordcloud.to_image()
#image.show()
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