import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from scipy.stats import kde
# Sample data
np.random.seed(42)
x = np.random.randn(100)
y = np.random.randn(100)
z = np.random.randn(100)
# Create figure and 3D axes
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
# Scatter plot
ax.scatter(x, y, z, c='b', marker='o')
# KDE for projections
def kde_projection(data1, data2):
values = np.vstack([data1, data2])
kernel = kde.gaussian_kde(values)
x_range = np.linspace(data1.min(), data1.max(), 100)
y_range = np.linspace(data2.min(), data2.max(), 100)
X, Y = np.meshgrid(x_range, y_range)
positions = np.vstack([X.ravel(), Y.ravel()])
Z = np.reshape(kernel(positions).T, X.shape)
return X, Y, Z
# Projections with KDE
# XY plane
X_xy, Y_xy, Z_xy = kde_projection(x, y)
ax.contour(X_xy, Y_xy, Z_xy, zdir='z', offset=z.min()-1, cmap='Blues')
# XZ plane
X_xz, Z_xz, Y_xz = kde_projection(x, z)
ax.contour(X_xz, Y_xz, Z_xz, zdir='y', offset=y.min()-1, cmap='Reds')
# YZ plane
Y_yz, Z_yz, X_yz = kde_projection(y, z)
ax.contour(X_yz, Y_yz, Z_yz, zdir='x', offset=x.min()-1, cmap='Greens')
# Set labels and limits
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_xlim(x.min() - 1, x.max() + 1)
ax.set_ylim(y.min() - 1, y.max() + 1)
ax.set_zlim(z.min() - 1, z.max() + 1)
# Show plot
plt.show()
It correcly plots the yz and xy projections onto their respective planes, but xz doesn't want to work... I'm not sure if I'm missing something, but I think the pattern should hold for all three Flugzeuge.
Thanks.
Kann mir jemand sagen, warum die XZ-Projektion in diesem Code nicht in der X-Z-Ebene erscheint? < /p> [code]import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np from scipy.stats import kde
# Sample data np.random.seed(42) x = np.random.randn(100) y = np.random.randn(100) z = np.random.randn(100)
# Create figure and 3D axes fig = plt.figure(figsize=(10, 8)) ax = fig.add_subplot(111, projection='3d')
# Scatter plot ax.scatter(x, y, z, c='b', marker='o')
# KDE for projections def kde_projection(data1, data2): values = np.vstack([data1, data2]) kernel = kde.gaussian_kde(values)
x_range = np.linspace(data1.min(), data1.max(), 100) y_range = np.linspace(data2.min(), data2.max(), 100) X, Y = np.meshgrid(x_range, y_range) positions = np.vstack([X.ravel(), Y.ravel()]) Z = np.reshape(kernel(positions).T, X.shape) return X, Y, Z
# Projections with KDE # XY plane X_xy, Y_xy, Z_xy = kde_projection(x, y) ax.contour(X_xy, Y_xy, Z_xy, zdir='z', offset=z.min()-1, cmap='Blues')
# Show plot plt.show() [/code] [img]https://i.sstatic.net/KnOJrpFG.png[/img]
It correcly plots the yz and xy projections onto their respective planes, but xz doesn't want to work... I'm not sure if I'm missing something, but I think the pattern should hold for all three Flugzeuge. Thanks.
Um eine Kamera -Kalibrierungsbibliothek zu testen, schrieb ich ein Python -Skript mit Pyrender, in dem ich eine Lochkamera eingerichte, um eine Gitterkreisplatine zu erfassen. Der Code ist verfügbar...
Um eine Kamera -Kalibrierungsbibliothek zu testen, schrieb ich ein Python -Skript mit Pyrender, in dem ich eine Lochkamera eingerichte, um eine Gitterkreisplatine zu erfassen. Der Code ist verfügbar...
Ich möchte, dass Dateninformationen angezeigt werden, wenn ich mit der Maus über eine Linie in Pyqtgraph-Diagrammen fahre, aber ich kann meine sigpointsHovered nicht dazu bringen, ein Signal...