Created
May 17, 2016 17:27
-
-
Save VikingMew/2372a36fca11f5a60a91c00d0319a00e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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