【发布时间】:2015-05-01 10:22:11
【问题描述】:
我正在使用带有一些 txt 文件的 word cloud。如果我想 1) 提高分辨率和 2) 删除空边框,我该如何更改 this example。
#!/usr/bin/env python2
"""
Minimal Example
===============
Generating a square wordcloud from the US constitution using default arguments.
"""
from os import path
import matplotlib.pyplot as plt
from wordcloud import WordCloud
d = path.dirname(__file__)
# Read the whole text.
text = open(path.join(d, 'constitution.txt')).read()
wordcloud = WordCloud().generate(text)
# Open a plot of the generated image.
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
【问题讨论】:
标签: python matplotlib word-cloud