pycloudtag 标签云

原创,转载请标明

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‘]

时间: 2024-08-29 04:13:10

pycloudtag 标签云的相关文章

Python word_cloud 样例 标签云系列(三)

转载地址:https://zhuanlan.zhihu.com/p/20436642word_cloud/examples at master · amueller/word_cloud · GitHub 上面是官方样例.这一篇里的大部分尝试都基于这些样例进行修改.前提是你已经完成了安装,依照上一篇修改了 FONT_PATH . 还记得 http://zhuanlan.zhihu.com/666666/20432734 里提到的中文分词方法吧,这次我们就不再赘述对文本的预处理了.有所不同的是,在

怎样在自己的Blog中展现3D标签云效果

在用Wordpress创建自己的Blog后,怎样在自己的Blog中安装绚丽的标签3D云呢?本文将带怎样用插件来实现这个3D标签云的效果. 我用的插件为:3D TagCloud 步骤一:打开Wordpress的编辑页面,选择插件,如下图所示:(http://localhost/wpc/wp-admin/) 步骤二:安装完成之后,启动这个插件. 步骤三:设置配置参数(3D Tag Cloud),详细参数如下图所示: 步骤四:进入Blog文章页面,看实际效果如下图所示:(http://localhos

[HTML5]3D标签云

index.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>3D标签云</title> <link rel="stylesheet" type="text/css" href="http://webapplee-

Python jquery标签云

很多知名博主都喜欢弄个标签云.今天特地看了下源码.把标签云的方法单独扣了出来.这里做一下记录 html页面代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml&q

在hexo静态博客中利用d3-cloud来展现标签云

效果: http://lucyhao.com/tags/ hexo自带的tag cloud的标签展现不太美观,想能够展现出“云”效果的标签.在网上找到了d3-cloud这个项目,github地址:https://github.com/jasondavies/d3-cloud demo地址:https://www.jasondavies.com/wordcloud/ hexo生成的是静态博客,所以最后在网上看到的都是静态的内容,也就是说,我们的看到的标签云也是静态的已经生成好的内容,并不会随着刷新

[翻译] DKTagCloudView - 标签云View

DKTagCloudView 效果(支持点击view触发事件): Overview DKTagCloudView is a tag clouds view on iOS. It can generate a random and not intersects coordinates. DKTagCloudView是一个标签云效果的view,你可以用它来生成随机的效果,在坐标中任意散布. How To Get Started - 如何开始 Installation with CocoaPods -

3D球状标签云(兼容IE8)

看见一个很有趣的标签云,3D球状,兼容 IE 8,亲测可用!其他版本没有测试.觉得挺有意思就拿来记录下来,学习学习,本文下方会放出我看的文章地址,先看一下效果: 接下来是代码,html + css + js,不是基于jQuery的,所以不需要引入,代码复制下来就可以看到效果: <div id="div1"> <a href="http://www.cnblogs.com/ntt1219/">忘了滋味</a> <a href=

wordpress主题开发:给标签云增加七彩背景色

本篇文章不是标签而是标签的背景色是七彩的,有点绕口令,还是看图说话,本篇要实现的七彩标签云背景色如图所示:要实现七彩标签云背景色代码也很简单,代码如下: <aside class="tags"><?php wp_tag_cloud('smallest=12&largest=12&number=45&order=DESC'); ?></aside> 把这段代码放在侧边栏sidebar.php即可(smallest,largest

Android自定义控件之自定义ViewGroup实现标签云(四)

前言: 前面几篇讲了自定义控件绘制原理Android自定义控件之基本原理(一),自定义属性Android自定义控件之自定义属性(二),自定义组合控件Android自定义控件之自定义组合控件(三),常言道:“好记性不如烂笔头,光说不练假把式!!!”,作为一名学渣就是因为没有遵循这句名言才沦落于此,所以要谨遵教诲,注重理论与实践相结合,今天通过自定义ViewGroup来实现一下项目中用到的标签云. 需求背景: 公司需要实现一个知识点的标签显示,每个标签的长度未知,如下图所示 基本绘制流程: 绘制原理