Skip to content

Instantly share code, notes, and snippets.

@VikingMew
Created May 17, 2016 17:27
Show Gist options
  • Select an option

  • Save VikingMew/2372a36fca11f5a60a91c00d0319a00e to your computer and use it in GitHub Desktop.

Select an option

Save VikingMew/2372a36fca11f5a60a91c00d0319a00e to your computer and use it in GitHub Desktop.
c = Counter(words)
# Read the whole text.
# Generate a word cloud image
wordcloud = WordCloud(max_font_size=40).generate_from_frequencies(c.items())
# Display the generated image:
# the matplotlib way:
import matplotlib.pyplot as plt
plt.imshow(wordcloud)
plt.axis("off")
# take relative word frequencies into account, lower max_font_size
wordcloud = WordCloud(max_font_size=40, relative_scaling=.5).generate_from_frequencies(c.items())
plt.figure()
plt.imshow(wordcloud)
plt.axis("off")
plt.savefig('cloud.png')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment