过零点应该是矢量吗?。在下面的代码中是元组df = pd.read_csv(file, delimiter = ',')
Convert series from data-frame into arrays
X = np.array(df['x'])
Y = np.array(df['y'])
Z = np.array(df['z'])
data = np.vstack([X, Y, Z])
# perform KDE
kernel = scipy.stats.kde.gaussian_kde(data)
density = kernel(data)
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
x, y, z = data
scatter = ax.scatter(x, y, z, c=density)
xmin = values[0].min()
xmax = values[0].max()
ymin = values[1].min()
ymax = values[1].max()
zmin = values[2].min()
zmax = values[2].max()
X,Y, Z = np.mgrid[xmin:xmax:100j,ymin:ymax:100j,zmin:zmax:100j]
positions = np.vstack([X.ravel(),Y.ravel(),Z.ravel()])
f = np.reshape(kernel(positions).T, X.shape)
derivative = np.gradient(f)
dz, dy, dx = derivative
xdiff = np.sign(dx) # along X-axis
ydiff = np.sign(dy) # along Y-axis
zdiff = np.sign(dz) # along Z-axis
xcross = np.where(xdiff[:-1] != xdiff[1:])
ycross = np.where([ydiff[:-1] != ydiff[1:]])
zcross = np.where([zdiff[:-1] != zdiff[1:]])
Zerocross = xcross + ycross + zcross