如何区分堆积条形图中的22个变量?

2024-05-13 08:50:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个熊猫数据框,包含75个样本(行)和22种不同人类细胞类型(列)的度量,如下所示:

import pandas as pd
import numpy as np
import plotly.plotly as py
import cufflinks as cf

cf.set_config_file(offline=False, world_readable=True, theme='ggplot')

#pandas dataframe:
df = pd.DataFrame(
np.random.rand(75, 22), columns=    
['B cells naive','B cells memory','Plasma cells','T cells CD8','T cells CD4 naive','T cells CD4 memory resting','T cells CD4 memory activated','T cells follicular helper','T cells regulatory (Tregs)','T cells gamma delta','NK cells resting','NK cells activated','Monocytes','Macrophages M0','Macrophages M1','Macrophages M2','Dendritic cells resting','Dendritic cells activated','Mast cells resting','Mast cells activated','Eosinophils','Neutrophils']
)

df.iplot(kind="bar", barmode="stack")

我想想象一下75个样本中22种细胞类型中的每一种有多少。所以我想用一个堆积条形图,每个条形图代表一个样本,堆积图显示样本中每个单元类型的估计数量。以下是使用Plotly生成的图形: Plotly Playground 2016-10-30 21-05-37.png

问题:堆叠条形图中表示的单元格类型没有唯一且可区分的颜色。例如,有三种单元类型具有相同的颜色(红色),这使得图形毫无意义,因为我们无法可视化每个样本中每个单元类型的频率。你知道吗

问题:有哪些可能的方法来区分每个样本的细胞类型。。。你知道什么颜色和/或图案可以用来解决这个问题吗?你知道吗

你认为除了堆积条形图之外,还有其他的可视化方法吗?你知道吗

谢谢!你知道吗


Tags: import类型pandas颜色as单元细胞样本