当前位置:网站首页>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)
## 我这里添加了方块了,下面的就好办了

边栏推荐
- On June 30, 2022, the record of provincial competition + national competition of Bluebridge
- Latex formula code
- How to troubleshoot SharePoint online map network drive failure?
- STM32 uses esp01s to go to the cloud, mqtt FX debugging
- Two expressions of string
- SQL number injection and character injection
- [untitled]
- 【刷题】字符统计【0】
- [getting started] enter the integer array and sorting ID, and sort its elements in ascending or descending order
- 【入门】提取不重复的整数
猜你喜欢

How to make the two financial transactions faster

【无标题】

Keithley 2100 software 𞓜 Keithley2400 test software ns SourceMeter
![[getting started] enter the integer array and sorting ID, and sort its elements in ascending or descending order](/img/87/07783593dbabcf29700fa207ecda08.png)
[getting started] enter the integer array and sorting ID, and sort its elements in ascending or descending order

038 network security JS

Gdip - hatchbrush pattern table

【入门】输入整型数组和排序标识,对其元素按照升序或降序进行排序

The H5 page has set the font thickness style, but the wechat access style in Huawei mobile phone doesn't take effect?

Basic knowledge of MATLAB

Why some people earn nearly 10billion a year, while others earn 3000 a month: the details you ignore actually make the most money
随机推荐
Android screen adaptation (using constraintlayout), kotlin array sorting
Anddroid 文本合成语音TTS实现
漏刻有时API接口实战开发系列(14):身份证实名鉴权验证
[getting started] input n integers and output the smallest K of them
Scala language learning-07-constructor
base64
SharePoint - modify web application authentication using PowerShell
Li Kou daily question - Day 32 -1822 Symbol of array element product
[batch DOS CMD summary] extension variables - delay variables CMD /v:on, CMD /v:off, SETLOCAL enabledelayedexpansion, disabledelayedexpansion
Precautions and skills in using regular expressions in golang
How to get a SharePoint online site created using the office365 group template
Differential: definition of total differential, partial derivative, gradient
Office365 - how to use stream app to watch offline files at any time
Soft keyboard height error
Significance and measures of source code encryption
Array: question brushing record
[getting started] intercepting strings
[untitled]
使用threejs简单Web3D效果
How to troubleshoot SharePoint online map network drive failure?