seaborn.heatmap操作手册

2023-10-27

本文转自seaborn.heatmap官方操作手册:http://seaborn.pydata.org/generated/seaborn.heatmap.html

heatmap很好,很强大!

seaborn.heatmap

seaborn0.9.0

seaborn.heatmap(datavmin=Nonevmax=Nonecmap=Nonecenter=Nonerobust=Falseannot=Nonefmt='.2g'annot_kws=Nonelinewidths=0linecolor='white'cbar=Truecbar_kws=Nonecbar_ax=Nonesquare=Falsexticklabels='auto'yticklabels='auto'mask=Noneax=None**kwargs)

Plot rectangular data as a color-encoded matrix.

This is an Axes-level function and will draw the heatmap into the currently-active Axes if none is provided to the ax argument. Part of this Axes space will be taken and used to plot a colormap, unless cbar is False or a separate Axes is provided to cbar_ax.

Parameters:

data : rectangular dataset

2D dataset that can be coerced into an ndarray. If a Pandas DataFrame is provided, the index/column information will be used to label the columns and rows.

vmin, vmax : floats, optional

Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments.

cmap : matplotlib colormap name or object, or list of colors, optional

The mapping from data values to color space. If not provided, the default will depend on whether center is set.

center : float, optional

The value at which to center the colormap when plotting divergant data. Using this parameter will change the default cmap if none is specified.

robust : bool, optional

If True and vmin or vmax are absent, the colormap range is computed with robust quantiles instead of the extreme values.

annot : bool or rectangular dataset, optional

If True, write the data value in each cell. If an array-like with the same shape as data, then use this to annotate the heatmap instead of the raw data.

fmt : string, optional

String formatting code to use when adding annotations.

annot_kws : dict of key, value mappings, optional

Keyword arguments for ax.text when annot is True.

linewidths : float, optional

Width of the lines that will divide each cell.

linecolor : color, optional

Color of the lines that will divide each cell.

cbar : boolean, optional

Whether to draw a colorbar.

cbar_kws : dict of key, value mappings, optional

Keyword arguments for fig.colorbar.

cbar_ax : matplotlib Axes, optional

Axes in which to draw the colorbar, otherwise take space from the main Axes.

square : boolean, optional

If True, set the Axes aspect to “equal” so each cell will be square-shaped.

xticklabels, yticklabels : “auto”, bool, list-like, or int, optional

If True, plot the column names of the dataframe. If False, don’t plot the column names. If list-like, plot these alternate labels as the xticklabels. If an integer, use the column names but plot only every n label. If “auto”, try to densely plot non-overlapping labels.

mask : boolean array or DataFrame, optional

If passed, data will not be shown in cells where mask is True. Cells with missing values are automatically masked.

ax : matplotlib Axes, optional

Axes in which to draw the plot, otherwise use the currently-active Axes.

kwargs : other keyword arguments

All other keyword arguments are passed to ax.pcolormesh.

Returns:

ax : matplotlib Axes

Axes object with the heatmap.

Examples

Plot a heatmap for a numpy array:

>>> import numpy as np; np.random.seed(0)
>>> import seaborn as sns; sns.set()
>>> uniform_data = np.random.rand(10, 12)
>>> ax = sns.heatmap(uniform_data)

../_images/seaborn-heatmap-1.png

Change the limits of the colormap:

>>> ax = sns.heatmap(uniform_data, vmin=0, vmax=1)

../_images/seaborn-heatmap-2.png

Plot a heatmap for data centered on 0 with a diverging colormap:

>>> normal_data = np.random.randn(10, 12)
>>> ax = sns.heatmap(normal_data, center=0)

../_images/seaborn-heatmap-3.png

Plot a dataframe with meaningful row and column labels:

>>> flights = sns.load_dataset("flights")
>>> flights = flights.pivot("month", "year", "passengers")
>>> ax = sns.heatmap(flights)

../_images/seaborn-heatmap-4.png

Annotate each cell with the numeric value using integer formatting:

>>> ax = sns.heatmap(flights, annot=True, fmt="d")

../_images/seaborn-heatmap-5.png

Add lines between each cell:

>>> ax = sns.heatmap(flights, linewidths=.5)

../_images/seaborn-heatmap-6.png

Use a different colormap:

>>> ax = sns.heatmap(flights, cmap="YlGnBu")

../_images/seaborn-heatmap-7.png

Center the colormap at a specific value:

>>> ax = sns.heatmap(flights, center=flights.loc["January", 1955])

../_images/seaborn-heatmap-8.png

Plot every other column label and don’t plot row labels:

>>> data = np.random.randn(50, 20)
>>> ax = sns.heatmap(data, xticklabels=2, yticklabels=False)

../_images/seaborn-heatmap-9.png

Don’t draw a colorbar:

>>> ax = sns.heatmap(flights, cbar=False)

../_images/seaborn-heatmap-10.png

Use different axes for the colorbar:

>>> grid_kws = {"height_ratios": (.9, .05), "hspace": .3}
>>> f, (ax, cbar_ax) = plt.subplots(2, gridspec_kw=grid_kws)
>>> ax = sns.heatmap(flights, ax=ax,
...                  cbar_ax=cbar_ax,
...                  cbar_kws={"orientation": "horizontal"})

../_images/seaborn-heatmap-11.png

Use a mask to plot only part of a matrix

>>> corr = np.corrcoef(np.random.randn(10, 200))
>>> mask = np.zeros_like(corr)
>>> mask[np.triu_indices_from(mask)] = True
>>> with sns.axes_style("white"):
...     ax = sns.heatmap(corr, mask=mask, vmax=.3, square=True)

../_images/seaborn-heatmap-12.png

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

seaborn.heatmap操作手册 的相关文章

  • 高并发情况下修改系统参数

    单进程最大打开文件数限制 一般的发行版 限制单进程最大可以打开1024个文件 这是远远不能满足高并发需求的 调整过程如下 在 号提示符下敲入 ulimit n 65535 限制修改失败了 会显示 Operationnotpermitted
  • 实战DeviceIoControl 之五:列举已安装的存储设备

    Q 前几次我们讨论的都是设备名比较清楚的情况 有了设备名 路径 就可以直接调用CreateFile打开设备 进行它所支持的I O操作了 如果事先并不能确切知道设备名 如何去访问设备呢 A访问设备必须用设备句柄 而得到设备句柄必须知道设备路径
  • 如何管理一个超过100人的研发团队?

    如何管理一个超过100人的研发团队 心得与体会 与大家共勉 1 无规矩不成方圆 因时因地制定合适灵活的策略和制度管理好团队和项目 2 欲善其事 必先利其器 是用合适的工具辅助团队和项目管理 2 不积硅步 无以至千里 鼓励技术 经验传承与分享
  • Unity 官方教程,坦克大战,AR版,联机版,PC版学习

    pc https pan lanzou com i0q5fyf 局域网 https pan lanzou com i0q5fyf EXE https pan lanzou com i0q5rle AR ASEET https pan lan
  • sql注入之万能密码总结

    万能密码 万能密码原理 原验证登陆语句 SELECT FROM admin WHERE Username username AND Password md5 password 输入 1 or 1 1 or 1 1万能密码语句变为 SELEC
  • Android 禁止输入表情符

    添加过滤器 mEtContent setFilters inputFilters 实现过滤器 private InputFilter inputFilters new InputFilter new InputFilter Pattern
  • 使用GCD处理后台线程和UI线程的交互(转自唐巧的技术博客)

    使用GCD FEB 22ND 2012 什么是GCD Grand Central Dispatch GCD 是Apple开发的一个多核编程的解决方法 该方法在Mac OS X 10 6雪豹中首次推出 并随后被引入到了iOS4 0中 GCD是
  • 运维技能风向标

    运维介绍 运维是一个融合多学科 网络 系统 开发 安全 应用架构 存储等 的综合性技术岗位 从最初的网络管理 网管 发展到现在的系统运维工程师 网络运维工程师 安全运维工程师 运维开发工程师等 可以看出 运维的分工一直在细化 并且对综合技能
  • S7-1200 PLC的数据类型

    S7 1200 PLC的数据类型 除了基本数据类型之外 还支持一些复杂的数据类型 包括结构数据类型Struct PLC数据类型UDT 数组Array 系统数据类型SDT 硬件数据类型DB ANY 参数数据类型Variant String和C
  • 巧妙利用kickstart实现自动化安装全get

    本文转载链接 https blog csdn net Nanjing bokebi article details 103035331 运用kickstart服务创建应答文件 实现自动化运维 运维自动化发展历程及技术应用 理解kicksta
  • BAJT 中高级 Java 面试题答案

    1 请问你做过哪些JVM优化 使用什么方法达到什么效果 vm调优主要也就是内存空间的分配 最终策略 提高系统性能 主要策略有 1 增加eden空间 让更多的对象留在年轻代 2 大对象直接放到老年代 以免扰乱年轻代高频率的gc XX Pete
  • MD5算法分析及逆向详解

    题外话 最近在看加密与解密 看到加密算法部分 感觉对于初次接触的新手还是有些难度的 故写下该篇文章 算作一个引导吧 新手飘过 老鸟勿笑 基本原理 MD5的典型应用是对一段信息 Message 产生信息摘要 Message Digest 以防
  • C/C++中浮点数的存储方式

    原文地址 C C 中浮点数的存储方式 作者 andyhzw 根据国际标准IEEE 754 任意一个二进制浮点数V可以表示成下面的形式 V 1 s M 2 E 1 1 s表示符号位 当s 0 V为正数 当s 1 V为负数 2 M表示有效数字
  • PostgreSQL jdbc 9.4 支持load balance 和 connection failover了

    Postgres2015全国用户大会将于11月20至21日在北京丽亭华苑酒店召开 本次大会嘉宾阵容强大 国内顶级PostgreSQL数据库专家将悉数到场 并特邀欧洲 俄罗斯 日本 美国等国家和地区的数据库方面专家助阵 Postgres XC
  • Cache 和 Buffer 有什么区别

    Cache 和 Buffer 有什么区别 转载 talkwithtrend https mp weixin qq com s YsEOBVS7fXgrGXnXH1I0MQ Cache和Buffer简单的说 Cache是加速 读 而buffe
  • SpringCloud与SpringBoot的版本对应关系

    在SpringCloud官网 https spring io projects spring cloud 可以看到 当前 2021年11月 SpringCloud的最新GA版本是2020 0 4这一版 除了2020 0 X版本外 Sprin
  • Java/JDK 21正式发布!15个特性一览

    订阅专栏 JDK 21已经于2023年9月19日正式发布 本文总结了JDK 21发布的新特性 发布版本说明 根据发布的规划 这次发布的 JDK 21 将是一个长期支持版 LTS 版 LTS 版每 2 年发布一个 上一次长期支持版是 21 年
  • 硬盘故障时如何强制关机:Input/output error

    如果硬盘可能会出现锁死或坏道的故障 会造成SHELL命令的失效 包括 reboot powoff shutdown 用正常的命令是没法完成重启的 执行这些命令 会出现如下IO报错 reboot bash sbin reboot Input
  • Unity 小球在两点之间往返运动

    在Vectoer3类中有一个Lerp方法 可以让一个物体从一个点到另外一个点 如果要在 这里点加往返运动我们可以借助Mathf PingPong 这个方法 这个方法会从0 Lenght持续增加 达到最大值后 持续减小 然后到0 如此反复 每
  • D3DXMESHOPT_ATTRSORT

    Mesh的顶点和索引能够被重组以便能更有效的渲染mesh 当我们这样做时 我们说我们优化了一个mesh 我们可以使用下面的方法来进行优化 HRESULT ID3DXMesh OptimizeInplace DWORD Flags CONST

随机推荐

  • 开发智能应用的新范式:大数据、AI和云原生如何构建智能软件

    文章目录 1 利用大数据实现智能洞察 2 集成人工智能和机器学习 3 云原生架构的弹性和灵活性 4 实现实时处理和响应 5 数据安全和隐私保护 6 可解释性和透明性 7 持续创新和迭代 8 数据伦理和合规性 个人主页 程序员 小侯 CSDN
  • Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apach

    1 启动tomcat报错的原因 可能是tomcat版本和JDK版本的兼容问题 2 下载其他版本的tomcat试试 我出错的时候是jdk1 7和tomcat9不兼容 将tomcat换成7版本的就可以啦
  • C语言 - 打印整数二进制的奇数位和偶数位

    define CRT SECURE NO WARNINGS include
  • 常用代码国家标准 目录列表

    编号 类别 中文名称 010001 GB T10114 1988 县以下行政区划代码编制规则 010002 GB T10301 1988 出国目的代码 010003 GB 11714 1997 全国组织机构代码编制规则 010004 GB
  • BTY-DNS AMA回顾:致力于创建Web3领域中的去中心化身份(DID)

    传统域名系统 DNS 是一个分层的分散信息存储 用于将用户在网络浏览器中输入可读名称 例如www baidu com 解析为IP地址 来访问互联网上的计算机 传统域名系统存在一些例如过于集中化管理 效率并不高等局限性问题 而去中心化域名正好
  • docker 配置私有仓库

    文章目录 修改配置文件 验证 修改配置文件 vim etc docker daemon json 输入内容 insecure registries 192 168 1 1 8081 添加 docker信任私有仓库地址 重启让配置生效 sys
  • Swagger

    目录 一 前言 二 Swagger介绍 三 使用 1 创建boot项目后导包springfox swagger2和springfox swagger ui 2 配置SwaggerConfig 3 注解 4 浏览器输入此连接在线查看 http
  • GAMES101-现代计算机图形学学习笔记(02)

    GAMES101 现代计算机图形学学习笔记 02 Lecture 02 Review of Linear Algebra GAMES101 现代计算机图形学学习笔记 02 向量 向量定义 向量运算 向量单位化 向量加法的两种表示形式 向量乘
  • 前端post请求方式传参参数各种格式详解,form-data,application/x-www-form-urlencoded,application/json,text/xml

    前端传参参数各种格式详解 一 form data 二 application x www form urlencoded 三 application json 四 text xml 总结 一 form data enctype 等于 mul
  • 刷脸支付互联网巨头纷纷从线上走到线下

    支付的发展 跟零售业的活跃度息息相关 伴随近几年移动支付井喷的是电商 外卖 O2O 共享经济的崛起 而随着互联网巨头纷纷从线上走到线下 开始一轮又一轮的新零售布局 新一轮崛起大概率来自于线下的消费场景 蜻蜓是支付宝在2018年年底推出的一款
  • python爬虫之requests库post请求

    作为一名数据获取者 爬取网站数据的技能是必不可少的 而其中最基础 最常用的技能就是使用 requests 库进行网页数据爬取 在 requests 库中 get 和 post 请求是最常见的两个请求方式 今天我们来详细讲解 requests
  • 直流耦合、交流耦合区分

    在示波器或者数据采集的时候 经常会遇到交流耦合与直流耦合的概念 简单来说 我们采集到的信号总不会是理想波形 例如 在采集交流信号的时候 可能会混入直流分量 而在采集直流信号的时候 也有可能混入交流分量 1 交流耦合 是指在信号与采集点之间加
  • Python 函数 pass

    函数是仅在调用时运行的代码块 可以将数据 称为参数 传递给函数 函数可以返回数据 函数是组织好的 可重复使用的 用来实现单一 或相关联功能的代码段 函数能提高应用的模块性 和代码的重复利用率 已经知道Python提供了许多内建函数 比如pr
  • MMPose安装记录

    参考 GitHub open mmlab mmpose OpenMMLab Pose Estimation Toolbox and Benchmark 一 依赖环境 MMPose 适用于 Linux Windows 和 macOS 它需要
  • 华尔街留下的指标之王(附代码展示)

    一 写在前面的话 有人认为价格围绕价值上下波动 研究投资标的内在价值 于是就出现了基本面派 有人为价格反映了一切 所有的信息 包括基本面 都反映到了盘面价格中 于是就有了技术面派 从技术面派的角度讲 有人认为市场价格运动的方式是随机的 下一
  • 第8课 微信小程序双向数据绑定this.setData:

    第8课 微信小程序双向数据绑定 效果图上来吧 上面的输入框是input标签 输入的值与js代码中的data内的数据绑定 下面的显示文字是获取data内绑定的那个数据的值 微信没有v mode这种方法哦 所以只能这样实现数据动态绑定 实现双向
  • 全球及中国钢铁行业供需格局与未来前景分析报告2022版

    全球及中国钢铁行业供需格局与未来前景分析报告2022版 修订日期 2021年11月 搜索鸿晟信合研究院查看官网更多内容 第一章 钢铁产业概述 1 1 钢铁工业概念界定 1 1 1 钢铁的定义 1 1 2 钢铁工业的定义 1 1 3 钢铁行业
  • jwt解决需要登入才能调用接口的方案

    jwt解决登入才有权限访问的问题 第一步 引入依赖
  • Flutter之使用Overlay创建全局Toast并静态调用

    Toast在Android上是最常用的提示组件了 它的优势在于静态调用 全局显示 可以在任意你想要的地方调用他而丝毫不影响界面的布局 调用简单程度与Logger的调用不相上下 然而在Flutter中并没有给我们提供Toast的接口 想要实现
  • seaborn.heatmap操作手册

    本文转自seaborn heatmap官方操作手册 http seaborn pydata org generated seaborn heatmap html heatmap很好 很强大 seaborn heatmap seaborn0