本文整理汇总了Python中wordcloud.WordCloud.scale方法的典型用法代码示例。如果您正苦于以下问题:Python WordCloud.scale方法的具体用法?Python WordCloud.scale怎么用?Python WordCloud.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wordcloud.WordCloud
的用法示例。
在下文中一共展示了WordCloud.scale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: float
# 需要导入模块: from wordcloud import WordCloud [as 别名]
# 或者: from wordcloud.WordCloud import scale [as 别名]
count = float(count)
print "Sum: %f" % count
words = []
# get the words from the whitelist and calculate their frequences
sql = """SELECT word, count FROM word_whitelist ORDER BY `count` DESC"""
for word, frequency in query(sql):
words.append((word, float(frequency) / count))
print "Creating cloud."
from scipy.misc import imread
mask = imread(MASK_FILE)
# generate the world cloud. This takes a while because the library is not parallelized.
wordcloud = WordCloud(font_path="/usr/share/fonts/truetype/msttcorefonts/Georgia.ttf", ranks_only=True, max_words = len(words),
mask=mask, background_color="white")
wordcloud.fit_words(words)
print "Creating LOW RES image."
wordcloud.to_file(LOW_RES)
# low let's beef up the scale
wordcloud.scale = 12
print "Creating HI RES image."
img = wordcloud.to_image()
img.save(HIGH_RES, dpi=(100000,100000))