当前位置:网站首页>使用seaborn绘制热图
使用seaborn绘制热图
2022-06-21 12:50:00 【51CTO】
除了统计图表外,seaborn也可以绘制热图,而且支持聚类树的绘制,绘制热图有以下两个函数
1. heatmap, 绘制普通的热图
2. clustermap,绘制带聚类数的热图
1. heatmap
相比matplotlib的imshow功能,该函数提供了更加简洁的接口,可以轻松实现文字注释的添加等功能,基本用法如下
输出结果如下

在imshow中的部分参数在该函数中也是可以使用的,比如vmin, vmax,cmap等参数。除了通用参数外,该函数有两个特色,第一就是可以方便的添加分割线,使图片更加的美观,使用linescolor和linewidth参数指定分割线的颜色和宽度,用法如下
输出结果如下

第二个特色是添加数字注释,在单元格上显示对应的数值,用法如下
输出结果如下

2. clustermap
clustermap绘制带聚类数的热图,基本用法如下
输出结果如下

图中的聚类树是通过scipy模块中提供的距离矩阵和聚类算法实现的,通过method和metrix参数可以分别指定聚类算法和距离矩阵的算法。
对于可视化而言,我们常用的参数有以下3个,第一个standard_scale, 对数据进行标准化,比如按行进行标准化,用法如下
输出结果如下

第二个参数为z_score, zscore也是数据标准化的一种手段,按照行列计算zscore的用法如下
输出结果如下

第三个参数为row_color/col_color. 用来对行标签和列标签进行注释,用法如下
输出结果如下

以上只是介绍了两个函数的基本用法和常用参数,其实具体的参数还要很多,可以通过官网的API文档来详细学习每个参数的用法。
·end·

一个只分享干货的
生信公众号
边栏推荐
- 小程序直播互动功能运行在App里?
- TOOD: Task-aligned One-stage Object Detection
- curl常用参数详解及示例
- Apache ShardingSphere 5.1.2 发布|全新驱动 API + 云原生部署,打造高性能数据网关
- Shell process control - 35. Multi branch case conditional statements
- Educoder web exercises - structural elements
- Educator web exercise - grouping form elements
- Interpretation of tamigou project: 34% equity transfer of Jining Huayuan Project Management Co., Ltd
- Postgre SQL 支持的数据类型分类
- Educoder web exercises -- text level semantic elements
猜你喜欢

Educoder table label - basic table structure

Implementation principle and application practice of Flink CDC mongodb connector

Educoder Web练习题---结构元素

PHP uses grafika to synthesize pictures and generate poster images

如何阅读AI顶会论文?

高效远程办公手册| 社区征文

Eureka's timedsupersortask class (periodic task with automatic interval adjustment)

Flink CDC MongoDB Connector 的实现原理和使用实践

【深入理解TcaplusDB技术】TcaplusDB导入数据

Reading notes on how to connect the Internet ADSL
随机推荐
PingCAP 入选 2022 Gartner 云数据库“客户之声”,获评“卓越表现者”最高分
还在用generator生成xxx管理系统的CRUD代码?来看看我是怎么写的
Preliminary understanding of PostgreSQL (I)
【深入理解TcaplusDB技术】TcaplusDB业务数据备份
Questions and answers No. 43: application performance probe monitoring principle PHP probe
Memcached (high performance memory object cache)
PostgreSQL logical storage structure
uva11729
居家办公初体验之新得分享| 社区征文
Flink CDC MongoDB Connector 的实现原理和使用实践
centos7 部署mysql 环境
CVPR2022 | 上科大x小红书首次提出动作序列验证任务,可应用于体育赛事打分等多场景
Association condition of SQL left connection
Matplotlib drawing tips
【Appium踩坑】关闭inspector后打开weditor,uiautomator2.exceptions.NullPointerExceptionError: -32001 Jsonrpc er
『忘了再学』Shell流程控制 — 35、多分支case条件语句
Educator web exercise - grouping form elements
Sharing new experiences in home office | community essay solicitation
塔米狗分享:产权交易的方式及其产权交易市场数据化意义
[安洵杯 2019]easy_web-1