如何在阈值距离后获得新的点列表?

How to get new list of points after threshold distance?

我有一个带坐标的数组。我计算所有点之间的距离。现在我只想显示距离超过某个阈值的坐标。我如何在 python 中执行此操作?

import numpy as np
import scipy
import matplotlib.pylab as plt

dx = np.array([b-a for a,b in combinations (x,2)])
dy = np.array([b-a for a,b in combinations (y,2)])
all_distances = scipy.stats.pdist( np.array(list(zip(x,y))) )
all_distances

df3=all_distances[~(all_distances<=35)]
df4=all_distances[~(all_distances<=40)]
df5=all_distances[~(all_distances<=45)]

fig, ax = plt.subplots()
plt.scatter(df3)
plt.ylabel('dy')
plt.xlabel('dx')
plt.show()

下面你看到了所有距离的点,但现在我想要一个散点图,其中的点高于阈值 35

scatterplot

您可能正在寻找这样的东西

import numpy as np
from scipy.spatial.distance import pdist

combinations = np.array([(1,2), (3,4), (5,8), (10,12)])

all_distances = pdist( np.array(combinations))
print(all_distances)
print(all_distances[all_distances>3])

您可以对其他数组执行相同的操作,因此 plt.scatter(dx[all_distances>35], dy[all_distances>35]) 之类的方法可能会解决您的问题。