首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >使用Python绘制热图的库 pyHea

使用Python绘制热图的库 pyHea

作者头像
py3study
发布2020-01-09 12:33:19
发布2020-01-09 12:33:19
8840
举报
文章被收录于专栏:python3python3

pyHeatMap 详细介绍

这是一个生成热图的小程序,基于 Python 和 PIL 开发。

程序截图:

点击图

热图

安装:

通过 pip 安装:

代码语言:javascript
复制
pip install pyheatmap

通过 easy_install 安装:

代码语言:javascript
复制
easy_install pyheatmap

通过源码安装:

代码语言:javascript
复制
git clone git://github.com/oldj/pyheatmap.git
cd pyheatmap
python setup.py install

使用示例:

代码语言:javascript
复制
# -*- coding: utf-8 -*-

import urllib
from pyheatmap.heatmap import HeatMap

def main():

    # 下载测试数据
    url = "https://raw.github.com/oldj/pyheatmap/master/examples/test_data.txt"
    sdata = urllib.urlopen(url).read().split("\n")
    data = []
    for ln in sdata:
        a = ln.split(",")
        if len(a) != 2:
            continue
        a = [int(i) for i in a]
        data.append(a)

    # 开始绘制
    hm = HeatMap(data)
    hm.clickmap(save_as="hit.png")
    hm.heatmap(save_as="heat.png")

if __name__ == "__main__":
    main()
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/08/31 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 程序截图:
    • 点击图
    • 热图
  • 安装:
    • 通过 pip 安装:
    • 通过 easy_install 安装:
    • 通过源码安装:
  • 使用示例:
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档