当前位置:网站首页>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

边栏推荐
- How to make the two financial transactions faster
- Find the nearest n-th power of 2
- Li Kou daily question - day 31 -1790 Can a string exchange be performed only once to make two strings equal
- Transaction method call @transactional
- Principle and process of embossing
- Chinese font Gan: zi2zi
- Teach you how to apply for domestic trademark online step by step
- Saving db4i depth camera pictures with MATLAB
- 【入门】取近似值
- [untitled]
猜你喜欢

Principle and process of embossing

postgresql源码学习(26)—— Windows vscode远程调试Linux上的postgresql

Why some people earn nearly 10billion a year, while others earn 3000 a month: the details you ignore actually make the most money

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

Download xshell and xftp
![[untitled]](/img/be/3523d0c14d555b293673af2b6fbcff.jpg)
[untitled]

【入门】取近似值

LSTM of RNN

base64

Teach you how to apply for domestic trademark online step by step
随机推荐
谈谈数字化转型的几个关键问题
SQL number injection and character injection
ContentType所有类型对比
Erreur de hauteur du clavier souple
[MySQL learning notes27] stored procedure
[MySQL learning notes 25] SQL statement optimization
【入门】输入n个整数,输出其中最小的k个
[MySQL learning notes 26] view
Instead of houses, another kind of capital in China is rising
How to use layui to display the data in the database in the form of tables
[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)
Caesar
Why some people earn nearly 10billion a year, while others earn 3000 a month: the details you ignore actually make the most money
Chinese font Gan: zi2zi
How to prevent the other party from saying that he has no money after winning the lawsuit?
Insufficient executors to build thread pool
Lm08 mesh series mesh inversion (fine)
Aardio - Method of self constructed geticonhandle
Li Kou daily question - day 31 -202 Happy number
Scala language learning-07-constructor