forked from raviolli77/dataScience-UCSBProjectGroup-Syllabus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
33 lines (26 loc) · 762 Bytes
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
"""
Minimal Example
===============
Generating a square wordcloud from the Star Wars: A New Hope using default arguments.
All code generated by writers of word_cloud module (https://github.com/amueller/word_cloud)
Used for educational purposes
"""
from os import path
from wordcloud import WordCloud
d = path.dirname(__file__)
# Read the whole text.
text = open(path.join(d, 'a_new_hope.txt')).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)
#plt.axis("off")
# lower max_font_size
wordcloud = WordCloud(max_font_size=40).generate(text)
plt.figure()
plt.imshow(wordcloud)
plt.axis("off")
plt.show()