当前位置:网站首页>Adding color blocks to Seaborn clustermap matrix
Adding color blocks to Seaborn clustermap matrix
2022-07-01 08:09:00 【qq_ forty-five million seven hundred and fifty-nine thousand tw】
Use cases 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()
give the result as follows 
Use cases 2( Custom color )
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)
## I added a square here , The next one is easy

边栏推荐
- [MySQL learning notes 25] SQL statement optimization
- P4 安装bmv2 详细教程
- 【Redis】一气呵成,带你了解Redis安装与连接
- SharePoint - how to quickly check whether SharePoint is standard or enterprise edition?
- Li Kou daily question - day 31 -1502 Judge whether an arithmetic sequence can be formed
- How outlook puts together messages with the same discussion
- 程序员养生宝典
- Two expressions of string
- empirical study and case study
- Codeforces Round #803 (Div. 2) VP补题
猜你喜欢

Connect timed out of database connection
![[MySQL learning notes 25] SQL statement optimization](/img/01/cf0556961670bb43512caab8d5f4e5.png)
[MySQL learning notes 25] SQL statement optimization
![[redis] it takes you through redis installation and connection at one go](/img/ca/89cb18f0eeb835f021d6a2489681a1.png)
[redis] it takes you through redis installation and connection at one go

PostgreSQL source code learning (26) -- windows vscode remote debugging PostgreSQL on Linux

Airsim雷达相机融合生成彩色点云

Significance and measures of source code encryption

【入门】截取字符串

Learn reptiles for a month and earn 6000 a month? Tell you the truth about the reptile, netizen: I wish I had known it earlier

038 network security JS

Latex table
随机推荐
LM08丨网格系列之网格反转(精)
Five combination boxing, solving six difficult problems on campus and escorting the construction of educational informatization
[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)
How relational databases work
Erreur de hauteur du clavier souple
Source code analysis of open source API gateway APIs IX
力扣每日一题-第31天-202.快乐数
0 basic introduction to single chip microcomputer: how to use digital multimeter and precautions
Li Kou daily question - day 31 -202 Happy number
Deep learning systematic learning
【批处理DOS-CMD-汇总】扩展变量-延迟变量cmd /v:on、cmd /v:off、setlocal enabledelayedexpansion、DisableDelayedExpansion
源代码加密的意义和措施
P4 安装bmv2 详细教程
Lm08 mesh series mesh inversion (fine)
Precautions and skills in using regular expressions in golang
使用 setoolkit 伪造站点窃取用户信息
EDA open source simulation tool verilator beginner 6: debugging examples
Day5: scanner object, next() and nextline(), sequential structure, selection structure, circular structure
量化交易之读书篇 - 《征服市场的人》读书笔记
On June 30, 2022, the record of provincial competition + national competition of Bluebridge