当前位置:网站首页>通过函数seaborn.cubehelix_palette生成顺序调色板
通过函数seaborn.cubehelix_palette生成顺序调色板
2022-06-13 06:53:00 【承危】
沉舟侧畔千帆过,病树前头万木春。 ——刘禹锡
import numpy as np
import seaborn as sns
引言
- 本文主要对seaborn库中的调色板函数
cubehelix_palette进行简单说明 - 函数
cubehelix_palette通过cubehelix系统来生成顺序调色板(sequential palette)、且共有九个参数可以调整 - 实际上、本文并未总结出显著的规律性方法来调用该函数、但记住一些常用的调色板所对应的参数、并善于对参数进行微调可能才是更为有用的指导
正文开始
- 查看默认调色板、jupyter中直接调用函数
sns.cubehelix_palette()就可以显示 - 显然从明到暗、6种颜色
sns.palplot(sns.cubehelix_palette())

- 由于函数默认返回的是RGB元组列表(list of RGB tuples)、所以可以通过整数或者切片来选取调色板中的部分颜色
sns.palplot(sns.cubehelix_palette()[:: 2])

参数rot控制在调色板的范围内围绕色调轮旋转- 通过从-0.5到0.6且步长为0.1的循环来查看所生成的颜色表、
参数n_colors控制生成色块的数量
for rot in np.arange(start=-0.5, stop=0.6, step=0.1):
sns.palplot(sns.cubehelix_palette(n_colors=12, rot=rot))











参数start控制螺旋线开始的色调- 可以进行一些对比、这是不设置开始色调时生成的颜色表
sns.palplot(sns.cubehelix_palette(n_colors=8, rot=-.2))

- 同样循环改变参数start、且产生了和参数rot类似的效果
- 但并没有发现可循的规律…
for start in np.arange(start=0, stop=3, step=0.6):
sns.palplot(sns.cubehelix_palette(n_colors=8, rot=-.2, start=start))





参数gamma控制颜色的明暗、越小于1越亮、越大于1越暗
sns.palplot(sns.cubehelix_palette(n_colors=8, rot=0.2, gamma=0.1))
sns.palplot(sns.cubehelix_palette(n_colors=8, rot=0.2, gamma=0.5))
sns.palplot(sns.cubehelix_palette(n_colors=8, rot=0.2))
sns.palplot(sns.cubehelix_palette(n_colors=8, rot=0.2, gamma=1.5))
sns.palplot(sns.cubehelix_palette(n_colors=8, rot=0.2, gamma=2.5))





参数hue控制颜色的饱和度- 官网所给出的范围是从0到1、但超出来也并没有什么问题
for hue in np.arange(start=-0.5, stop=2.0, step=0.5):
sns.palplot(sns.cubehelix_palette(rot=0.5, hue=hue))





参数dark和参数light分别控制调色板/颜色表中最暗和最亮颜色的强度- 使用的时候慢慢调整到合适的、所需要的颜色吧
sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5, dark=0.05))
sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5))
sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5, dark=0.5))



sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5, light=0.3))
sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5, light=0.5))
sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5))



- 参数light取0.85、或参数dark取0.15为默认值
sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5)) == sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5, light=0.85))
True


sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5)) == sns.palplot(sns.cubehelix_palette(rot=-0.2, gamma=0.5, dark=0.15))
True


参数reverse可以将调色板从明到暗改为从暗到明
sns.palplot(sns.cubehelix_palette(rot=-0.5, gamma=0.5))
sns.palplot(sns.cubehelix_palette(rot=-0.5, gamma=0.5, reverse=True))


参数as_cmap可以将函数返回值从RGB元组列表改为matplotlib的colors.Colormap数据类型- 这样就可以通过顺序调色板函数
cubehelix_palette来设置其他绘图函数中的参数cmap
cmap = sns.cubehelix_palette(rot=-0.2, as_cmap=True, light=1)
sns.heatmap(data=np.arange(25).reshape(5, 5), cmap=cmap)

边栏推荐
- Smart finance is upgraded again, and jinglianwen technology provides data collection and labeling services
- Continuous management design
- 2022-06-12:在N*N的正方形棋盤中,有N*N個棋子,那麼每個格子正好可以擁有一個棋子。 但是現在有些棋子聚集到一個格子上了,比如: 2 0 3 0 1 0 3 0 0 如上的二維數組代錶,一
- 上位机开发(固件下载软件之详细设计)
- 百货中心供应链管理系统
- Notepad++ settings delete current line shortcut
- Learning notes of MySQL series by database and table
- 【马尔科夫链-蒙特卡罗】马尔科夫链-蒙特卡罗方法对先验分布进行抽样
- Tidb implementation plan -- I
- 15、 IO stream (I)
猜你喜欢
![[SketchUp 2021] sketch master's image output and rendering style description [edge setting, plane setting, background setting, watermark setting, modeling setting, sky background creating sky, creatin](/img/95/a86b461c547bab41b2053073275d24.png)
[SketchUp 2021] sketch master's image output and rendering style description [edge setting, plane setting, background setting, watermark setting, modeling setting, sky background creating sky, creatin

怎么写出一份令人惊叹的设计文档?

Why is the new e-commerce outlet mode so popular? What is the specific mode?
![[system analysis and design] college student association management system](/img/8f/a23dbdcba7c6afe7d7ce3abba2865c.jpg)
[system analysis and design] college student association management system

Smart finance is upgraded again, and jinglianwen technology provides data collection and labeling services

Xuanwu cloud technology passed the listing hearing: the performance fluctuated significantly, and chenyonghui and other three were the controlling shareholders

【马尔科夫链-蒙特卡罗】马尔科夫链-蒙特卡罗方法对先验分布进行抽样

How to quickly support the team leader to attract new fission users in the business marketing mode of group rebate?

上位机开发(固件下载软件之架构设计)

How to use Wangyou DFM software for cold plate analysis
随机推荐
Is it safe to open an account online in Hangzhou?
IIS batch bind domain name
Network planning common interview knowledge (I)
Custom attribute acquisition of view in applet
First day of learning MySQL Basics
Br tool backup recovery
Brief introduction to basic usage of echart
105. 从前序与中序遍历序列构造二叉树
想进行快速钢网设计,还能保证钢网质量? 来看这里
Tidb server tuning
Periodontitis investigation (ongoing)
景联文科技提供语音数据采集标注服务
Project analysis of Taishan crowdfunding mode: why is Taishan crowdfunding mode so popular?
【RS-422与RS-485】RS-422与RS-485串行接口标准
json. Stringify() and json The difference between parse () and json Usage of stringify()
[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution
What is online blind box e-commerce? Can blind box e-commerce become a new bonus market for the Internet?
How to make a development board from scratch? Illustrated and illustrated, step by step operation for you to see.
怎么写出一份令人惊叹的设计文档?
In kotlin?,!,?:,:, - & gt;、== Brief description of symbols