Win 10 x 64 Anaconda Python 2.7Convert Plot in ein Oberflächendiagramm, Matplotlib?
Ich bin mit dem folgenden Code eine Evolventen-Spirale auf eine Gauß-Oberfläche aufgetragen ..
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Spiral parameters
samNum = 1000
spConst = 10.0
t = np.linspace(0, 6*np.pi, samNum)
# Coordinates of involute spiral on xy-plane
coords = np.zeros([samNum, 3])
coords[:,0] = spConst * (np.cos(t) + t * np.sin(t)) # x coord
coords[:,1] = spConst * (np.sin(t) - t * np.cos(t)) # y coord
# Paramters for 2D Gaussian surface
amp = 200
sigma_x = 75.0
sigma_y = 75.0
theta = np.pi
a = np.cos(theta)**2/(2 * sigma_x**2) + np.sin(theta)**2/(2 * sigma_y**2)
b = -np.sin(2 * theta)/(4 * sigma_x**2) + np.sin(2 * theta)/(4 * sigma_y**2)
c = np.sin(theta)**2/(2 * sigma_x**2) + np.cos(theta)**2/(2 * sigma_y**2)
# z coords of spiral projected onto Gaussian surface
coords[:,2] = amp * np.exp(-(a * coords[:,0]**2 - 2 * b * coords[:,0]*coords[:,1] + c * coords[:,1]**2)) # z coord
# plot 3D spiral
ax.scatter(coords[:,0], coords[:,1], coords[:,2], s=1, c='k')
# plot lines projecting 3D spiral on to the xy-plane
for p in range(samNum):
ax.plot([coords[p,0], coords[p,0]], [coords[p,1], coords[p,1]], [0, coords[p,2]], color='g', linewidth=0.1)
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
Die folgende Ausgabe gibt ...
Ich möchte das grüne Band in eine kontinuierliche Oberfläche umwandeln. Ich habe mir parametrische Oberflächen in matplotlib
angesehen, aber ich kann nicht verstehen, wie man diese in eine Oberfläche umwandelt.
So ist das möglich? Alle Hinweise geschätzt.
Ich denke, die 'meshgrid' ich bin zu kämpfen. Was betrachte ich, wenn ich X, Y & Z betrachte? Ich kann das sehen, X [0,:] = X [1,:] '(Gleiches mit Y), aber kann nicht meinen Kopf herum, warum das tun? Was sind diese "Meshgrid" -Objekte (nein, ich kann weder Head noch Tail von den 'Meshgrid'-Dokumenten machen). Mache ich einen Sinn? – DrBwts
Ist das ein Problem zu verstehen, wie 'Meshgrid' funktioniert oder ein Problem, warum die Rückkehr von' Meshgrid' ideal ist, um die Art von Handlung zu erzeugen, die wir hier haben? (Auf jeden Fall habe ich das Gefühl, dass ich im Kommentarabschnitt einer anderen Frage keine gute Antwort geben kann.) – ImportanceOfBeingErnest
ist beides, um ehrlich zu sein. – DrBwts