当前位置: 首页>>代码示例>>Python>>正文


Python WordCloud.scale方法代码示例

本文整理汇总了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))
开发者ID:iannightingale,项目名称:cs109,代码行数:33,代码来源:wordCloud.py


注:本文中的wordcloud.WordCloud.scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。