Ich versuche, einen Asteroiden mit plot_surface
und plot_wireframe
zu modellieren. Ich habe x y und z Werte für die Punkte auf der Oberfläche des Asteroiden. Das Drahtmodell ist genau auf die Form des Asteroiden abgestimmt, aber das Oberflächendiagramm passt nicht zum Drahtmodell. Wie kann ich das Oberflächendiagramm an das Drahtmodell anpassen oder wie kann ich das Drahtmodell verwenden, um ein 3D-Körpermodell zu erhalten? Hier ist mein Code für das Modell:Modellierung eines Asteroiden mit Matplotlib mit der Oberfläche und Drahtmodell
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
from matplotlib.mlab import griddata
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
data = np.genfromtxt('data.txt')
x = data[:,0]
y = data[:,1]
z = data[:,2]
ax.plot_wireframe(x, y, z, rstride=1, cstride=1, alpha=1)
xi = np.linspace(min(x), max(x))
yi = np.linspace(min(y), max(y))
X, Y = np.meshgrid(xi, yi)
Z = griddata(x, y, z, xi, yi)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax.set_zlim(-1.01, 1.01)
plt.show()
Die Daten in diesem Format ist, obwohl es viel mehr Zeilen in der Originaldatei sind:
-1.7738946051191869E-002 4.3461451610545973E-002 1.3393057231408241
-0.29733561550902488 0.32305812106837900 1.3393057231408241
-0.29733561550902488 0.16510132228266330 1.3548631099230350
-0.21872587865015569 2.4170900455101410E-002 1.3610011616437809
1.4452975249810950E-002 -0.20900795344486520 1.3610011616437809
1.5732454381265970E-002 -0.20900795344486520 1.3608751439485580
-0.34501536374240321 0.51320241386595655 1.3158820995876130
-0.40193014435941982 0.45628763324893978 1.3158820995876130
-0.42505849480150409 0.28183419537116011 1.3307863198123011
-0.18994178462386799 -0.19294290416565860 1.3424523041534830
1.4452975249810939E-002 -0.39733766403933751 1.3424523041534830
5.8021940902131752E-002 -0.57108837516584876 1.3210481842104100
9.3746267961881152E-002 -0.61017602710257668 1.3136798474111200
0.26609469681891229 -0.43782759824554562 1.3136798474111200
0.17938460413447810 0.39179924148155021 1.2357401964919650
8.9613011902522258E-002 0.42818009222325598 1.2584008460875080
0.33671539027096409 -0.47165177581327772 1.2965073126705291
0.53703772594296528 -0.47165177581327777 1.2357401964919561
-0.19242375014122229 0.71021685426700043 1.2584008460875080
-0.34501536374240321 0.66763766324752027 1.2904902860951690
Hoffnung können Sie
ich in http://code.enthought.com/projects/mayavi/ suchen würde empfehlen, die 'vtk' und bietet viel bessere 3D nutzt Unterstützung als 'Matplotlib'. – tacaswell
Interessantes Problem, können Sie einen Link zu den vollständigen Daten veröffentlichen? –
Ich stimme @tcaswell zu: Matplotlibs 3D ist nicht wirklich dazu bereit; siehe http://stackoverflow.com/questions/6030098/how-to-display-a-3d-plot-of-a-3d-array-isosurface-in-matplotlib-mplot3d-or-simil für die Verwendung von mayavi render isooberflächen von 3D Volumendaten (nicht ganz das gleiche Problem). – timday