原创,转载请标明
QQ:231469242
# -*- coding: utf-8 -*- """Python3.0 Created on Sat Nov 26 08:54:26 2016 需要的安装包 pip install pytagcloud pip install pygame pip install simplejson @author: daxiong """ import pytagcloud #wordcounts 是一个列表,元素是元组 wordcounts=[("python",5),("love",2),("work",1)] tags = pytagcloud.make_tags(wordcounts) pytagcloud.create_tag_image(tags, ‘cloud_large.png‘, size=(900, 600))
说明文档
help(make_tags)
Help on function make_tags in module pytagcloud:
make_tags(wordcounts, minsize=3, maxsize=36, colors=None, scalef=<function defscale at 0x000000001082FBF8>)
sizes and colors tags
wordcounts is a list of tuples(tags, count). (e.g. how often the
word appears in a text)
the tags are assigned sizes between minsize and maxsize, the function used
is determined by scalef (default: square root)
color is either chosen from colors (list of rgb tuples) if provided or random
dir(pytagcloud)
Out[39]:
[‘CONVMASK‘,
‘DEFAULT_FONT‘,
‘DEFAULT_PALETTE‘,
‘ECCENTRICITY‘,
‘FONT_CACHE‘,
‘FONT_DIR‘,
‘Group‘,
‘LAST_COLLISON_HIT‘,
‘LAYOUTS‘,
‘LAYOUT_HORIZONTAL‘,
‘LAYOUT_MIX‘,
‘LAYOUT_MOST_HORIZONTAL‘,
‘LAYOUT_MOST_VERTICAL‘,
‘LAYOUT_VERTICAL‘,
‘LOWER_START‘,
‘RADIUS‘,
‘Rect‘,
‘SRCALPHA‘,
‘STEP_SIZE‘,
‘Sprite‘,
‘Surface‘,
‘TAG_PADDING‘,
‘Tag‘,
‘UPPER_START‘,
‘__builtins__‘,
‘__cached__‘,
‘__doc__‘,
‘__file__‘,
‘__loader__‘,
‘__name__‘,
‘__package__‘,
‘__path__‘,
‘__spec__‘,
‘__warningregistry__‘,
‘_archimedean_spiral‘,
‘_do_collide‘,
‘_draw_cloud‘,
‘_get_group_bounding‘,
‘_get_tags_bounding‘,
‘_rectangular_spiral‘,
‘_search_place‘,
‘ceil‘,
‘choice‘,
‘collide_mask‘,
‘colorsys‘,
‘convsurf‘,
‘copy‘,
‘cos‘,
‘create_html_data‘,
‘create_tag_image‘,
‘defscale‘,
‘draw‘,
‘font‘,
‘lang‘,
‘load_font‘,
‘make_tags‘,
‘mask‘,
‘math‘,
‘os‘,
‘pygame‘,
‘randint‘,
‘simplejson‘,
‘sin‘,
‘transform‘]