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

边栏推荐
- [batch dos-cmd command - summary and summary] - Common operators in the CMD window (<, < <, & <,>, > >, & >, & >, & &, ||, (),;, @)
- Scala语言学习-07-构造器
- Differential: definition of total differential, partial derivative, gradient
- Uni hot update
- Latex formula code
- Wang Yingqi, founder of ones, talks to fortune (Chinese version): is there any excellent software in China?
- String coordinates of number to excel
- STM32 uses esp01s to go to the cloud, mqtt FX debugging
- EDA开源仿真工具verilator入门6:调试实例
- Missing API interface actual development series (14): ID card real name authentication verification
猜你喜欢

She is the "HR of others" | ones character

Cyclic neural network
![[kv260] generate chip temperature curve with xadc](/img/fc/e5e4648b09b1123b2d494b75a9f8f7.png)
[kv260] generate chip temperature curve with xadc

Microsoft stream - how to modify video subtitles

Keithley 2100 software 𞓜 Keithley2400 test software ns SourceMeter

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

5大组合拳,解决校园6大难题,护航教育信息化建设

Access report realizes subtotal function

Caesar

【入门】输入n个整数,输出其中最小的k个
随机推荐
使用threejs简单Web3D效果
ContentType所有类型对比
力扣每日一题-第32天-1822.数组元素积的符号
Aardio - 阴影渐变文字
Microsoft stream - how to modify video subtitles
How to use layui to display the data in the database in the form of tables
【力扣10天SQL入门】Day9 控制流
一套十万级TPS的IM综合消息系统的架构实践与思考
LSTM of RNN
How to troubleshoot SharePoint online map network drive failure?
Long way to go with technology
Gru of RNN
[getting started] input n integers and output the smallest K of them
Software testing methods and techniques - overview of basic knowledge
凸印的印刷原理及工艺介绍
STM32 uses esp01s to go to the cloud, mqtt FX debugging
【无标题】
Thesis learning -- Analysis and Research on similarity query of hydrological time series
【力扣10天SQL入门】Day10 控制流
Array: question brushing record