1

我有形状为 (13, 2236, 1866) 的 ndarray。我想为每个维度与所有其他维度创建散点图,例如 dim1 +dim2, dim1 + dim3, dim1 +dim4 ...sdim2+dim3, dom2+4........ 直到我得到散点图所有可能性的情节。

现在我有使用 while 循环的脚本,但是 ofcurse 没有找到所有匹配的可能性。#array= ndarray

d=0
while d+1<13:
    x=array[d].reshape(-1)
    y=array[d+1].reshape(-1)    
    plt.figure(figsize=(8,6))
    plt.scatter(x, y, s=5, linewidth=0)
    plt.scatter(x, y,s=5, linewidth=0)
    plt.xlabel('B{band1}'.format(band1= str(d+1)))
    plt.ylabel('B{band2}'.format(band2 = str(d+2)))
    plt.show()
    d=d+1

在这里,我得到了 B1+B2、B2+B3、B3+B4 的可能性...我还尝试创建尺寸列表和使用 for 循环:

dims=np.arange(0,13)

然后“for d in dims”运行 while 循环,但这也没有给出所有的可能性。

我的最终目标:为所有维度创建所有可能的散点图

4

1 回答 1

0

最后我使用了这里的函数:

dims=np.arange(0,13)


def tessa(source):
        result = []
        for p1 in range(len(source)):
                for p2 in range(p1+1,len(source)):
                        result.append([source[p1],source[p2]])
        return result

pairings = tessa(dims)
print("%d pairings" % len(pairings))

        
        
for i in pairings:
    xd=i[0]
    xy=i[1]
    x=array[xd].reshape(-1)
    y=array[xy].reshape(-1)    
    plt.figure(figsize=(8,6))
    plt.scatter(x, y, s=5, linewidth=0)
    plt.scatter(x, y,s=5, linewidth=0)
    plt.xlabel('B{band1}'.format(band1= str(xd+1)))
    plt.ylabel('B{band2}'.format(band2 = str(xy+1)))
    plt.show()
于 2020-12-08T16:31:35.747 回答