有没有办法从a
to b
下图中有脚本吗?我在用seaborn.clustermap()
到达,得到a
(即保留行的顺序。但是,列顺序仅在第二最高级别更改)。
I was wondering whether it is possible to use the seaborn.matrix.ClusterGrid
that is returned by seaborn.clustermap()
, modify it and plot the modified results.
b
P.S. The reason I am asking this is that the order has a meaning (first comes blue, next green, and finally red).
Update:下面是一个小数据集生成的情况:
df = pd.DataFrame([[1, 1.1, 0.9, 1.9, 2, 2.1, 2.8, 3, 3.1],
[1.8, 2, 2.1, 0.7, 1, 1.1, 2.7, 3, 3.3]],
columns = ['d1', 'd2', 'd3',
'l3', 'l2', 'l1',
'b1', 'b2', 'b3'],
index = ['p1', 'p2'])
cg = sns.clustermap(df); ## returns a ClusterGrid
输出是这样的:
我们可以想到以以下开头的列b
作为早餐,l
作为午餐和d
作为晚餐。现在,命令是breakfast -> dinner -> lunch
。我想去breakfast -> lunch -> dinner
.