Mercurial > hg > python
view simpleCloud.py @ 76:cba9cb3a6797
from python3.13 with block boundary tracking added by HST
| author | Henry S Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Thu, 12 Mar 2026 18:06:10 +0000 |
| parents | e07789816ca5 |
| children |
line wrap: on
line source
#!/usr/bin/env python """ Minimal Example =============== Generating a square wordcloud from a text file using default arguments. """ import sys from os import path from wordcloud import WordCloud from matplotlib import use use('pdf') # Read the whole text. text = open(sys.argv[1]).read() # Generate a word cloud image wordcloud = WordCloud().generate(text) # Display the generated image: # the matplotlib way: import matplotlib.pyplot as plt plt.imshow(wordcloud, interpolation='bilinear') plt.axis("off") # lower max_font_size wordcloud = WordCloud(max_font_size=40).generate(text) plt.figure() plt.imshow(wordcloud, interpolation="bilinear") plt.axis("off") plt.savefig('/tmp/cloud.pdf')
