[英]Plotting a heat map for a data frame row that contains distance measures of agents
I have a data frame of 3000 rows x 101 columns like as follow: 我有一个3000行x 101列的数据框,如下所示:
Time id0 id1 id2 ………… id99
1 1.71 6.99 4.01 ………… 4.98
2 1.72 6.78 3.15 ………… 4.97
.
.
3000 0.36 0.23 0.14 ………… 0.28
In fact the measures in the 100 columns (from id0 to id99) represent distances of agents in a global coordinate frame. 实际上,这100列(从id0到id99)中的度量表示代理在全局坐标系中的距离。
Is it possible to generate a heatmap for a given row in a way that the related (100x100) matrix contains the differences in distance between each pair of agent (id_i - id_j , with i and j /in {0..99}). 是否可以通过相关(100x100)矩阵包含每对代理之间的距离差异(id_i-id_j,其中i和j / in {0..99})来生成给定行的热图。
Ok, if I got it right now, that's what you'd like to have(?) 好吧,如果我现在知道的话,那就是您想要的东西(?)
A = np.random.randint(0, 10, 10)
M = [A - x for x in A]
fig, ax = plt.subplots()
seaborn.heatmap(M)
plt.show()
#A
array([1, 6, 0, 1, 5, 8, 1, 1, 9, 0])
#M:
[array([ 0, 5, -1, 0, 4, 7, 0, 0, 8, -1]),
array([-5, 0, -6, -5, -1, 2, -5, -5, 3, -6]),
array([ 1, 6, 0, 1, 5, 8, 1, 1, 9, 0]),
array([ 0, 5, -1, 0, 4, 7, 0, 0, 8, -1]),
array([-4, 1, -5, -4, 0, 3, -4, -4, 4, -5]),
array([-7, -2, -8, -7, -3, 0, -7, -7, 1, -8]),
array([ 0, 5, -1, 0, 4, 7, 0, 0, 8, -1]),
array([ 0, 5, -1, 0, 4, 7, 0, 0, 8, -1]),
array([-8, -3, -9, -8, -4, -1, -8, -8, 0, -9]),
array([ 1, 6, 0, 1, 5, 8, 1, 1, 9, 0])]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.