Commit 031449e2 authored by Andreas Mueller's avatar Andreas Mueller

adjust simple example to new interface

parent c1014d10
examples/alice.png

446 KB | W: | H:

examples/alice.png

138 KB | W: | H:

examples/alice.png
examples/alice.png
examples/alice.png
examples/alice.png
  • 2-up
  • Swipe
  • Onion skin
examples/constitution.png

56.1 KB | W: | H:

examples/constitution.png

54.5 KB | W: | H:

examples/constitution.png
examples/constitution.png
examples/constitution.png
examples/constitution.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -20,7 +20,13 @@ plt.imshow(alice_mask)
wc = WordCloud(background_color="white", max_words=2000, mask=alice_mask,
stopwords=STOPWORDS.add("said"))
# generate word cloud
wc.generate(text)
# store to file
wc.to_file(path.join(d, "alice.png"))
# show
plt.figure()
plt.imshow(wc)
plt.show()
#!/usr/bin/env python2
from os import path
import sys
import wordcloud
from wordcloud import WordCloud
d = path.dirname(__file__)
# Read the whole text.
text = open(path.join(d, 'constitution.txt')).read()
# Separate into a list of (word, frequency).
words = wordcloud.process_text(text)
# Compute the position of the words.
elements = wordcloud.fit_words(words)
wordcloud = WordCloud().generate(text)
# Draw the positioned words to a PNG file.
wordcloud.draw(elements, path.join(d, 'constitution.png'))
wordcloud.to_file(path.join(d, 'constitution.png'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment