当前位置:网站首页>seaborn clustermap矩阵添加颜色块
seaborn clustermap矩阵添加颜色块
2022-07-01 08:05:00 【qq_45759229】
使用案例1
import seaborn as sns; sns.set(color_codes=True)
import matplotlib.pyplot as plt
import pandas as pd
iris = sns.load_dataset("iris")
print(iris)
species = iris.pop("species")
lut1 = dict(zip(species.unique(), ['#ED2323','#60FD00','#808080']))
row_colors1 = species.map(lut1)
lut2 = dict(zip(species.unique(), "rbg"))
row_colors2 = species.map(lut2)
row_colors = pd.concat([row_colors1,row_colors2],axis=1)
print(row_colors)
g = sns.clustermap(iris, row_colors=row_colors, col_cluster=False,cmap="mako", yticklabels=False, xticklabels=False)
plt.show()
结果如下
使用案例2(自定义颜色)
import seaborn as sns; sns.set_theme(color_codes=True)
iris = sns.load_dataset("iris")
species = iris.pop("species")
sample=20
iris=iris.head(20)
species=species.head(sample)
g = sns.clustermap(iris)

colors_use=['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#bcbd22', '#17becf', '#aec7e8', '#ffbb78', '#98df8a', '#ff9896', '#bec1d4', '#bb7784', '#0000ff', '#111010', '#FFFF00', '#1f77b4', '#800080', '#959595',
'#7d87b9', '#bec1d4', '#d6bcc0', '#bb7784', '#8e063b', '#4a6fe3', '#8595e1', '#b5bbe3', '#e6afb9', '#e07b91', '#d33f6a', '#11c638', '#8dd593', '#c6dec7', '#ead3c6', '#f0b98d', '#ef9708', '#0fcfc0', '#9cded6', '#d5eae7', '#f3e1eb', '#f6c4e1', '#f79cd4']
#lut = dict(zip(species.unique(), colors_use))
row_colors = colors_use[:sample]
g = sns.clustermap(iris, row_colors=row_colors)
## 我这里添加了方块了,下面的就好办了

边栏推荐
- OJ input and output exercise
- [question brushing] character statistics [0]
- 【mysql学习笔记28】存储函数
- 数字转excel的字符串坐标
- Saving db4i depth camera pictures with MATLAB
- matlab保存DB4i深度相机图片
- Implementation and encapsulation of go universal dynamic retry mechanism
- Access报表实现小计功能
- 力扣每日一题-第31天-1790.仅执行一次字符串交换能否使两个字符串相等
- EDA open source simulation tool verilator beginner 6: debugging examples
猜你喜欢

Wang Yingqi, founder of ones, talks to fortune (Chinese version): is there any excellent software in China?

Serial port oscilloscope software ns-scope

软键盘高度报错
![[staff] key number (key number identification position | key number marking list | a major key identification principle | F, C, G position marking ascending | F major key identification principle | B](/img/48/e98d01830867baa742574e1b6e1096.jpg)
[staff] key number (key number identification position | key number marking list | a major key identification principle | F, C, G position marking ascending | F major key identification principle | B

STM32 uses esp01s to go to the cloud, mqtt FX debugging

Differential: definition of total differential, partial derivative, gradient

OJ input and output exercise

谈谈数字化转型的几个关键问题

OJ输入输出练习

【入门】取近似值
随机推荐
How relational databases work
[force deduction 10 days SQL introduction] Day10 control flow
Microsoft stream - how to modify video subtitles
[getting started] intercepting strings
matlab保存DB4i深度相机图片
[batch dos-cmd command - summary and summary] - Common operators in the CMD window (<, < <, & <,>, > >, & >, & >, & &, ||, (),;, @)
Significance and measures of source code encryption
slice扩容机制分析
[untitled]
【刷题】字符统计【0】
【入门】提取不重复的整数
Gru of RNN
【无标题】
Gdip - hatchbrush pattern table
SQL number injection and character injection
Analysis of slice capacity expansion mechanism
web254
EDA open source simulation tool verilator beginner 6: debugging examples
軟鍵盤高度報錯
OJ input and output exercise