2016-06-13 22 views
1

Ich versuche this mit meinem data zu tun, die die folgende Struktur aufweist:matplotlib contourf3d plot_surface vs. trisurf

0.90000000 0.90000000 -2133.80472139 
0.90000000 0.95000000 -2133.84134433 
... 
1.87500000 1.82500000 -2133.96171262 
1.87500000 1.87500000 -2133.95550450 

Mit folgendem Code habe ich teilweise erfolgreich. Allerdings kann ich die Konturen nicht auf den Ebenen x-y, x-z und y-z darstellen. Ich musste plot_trisurf verwenden, da die Option plot_surface für diese Daten nicht funktioniert (ich weiß wirklich nicht warum). Das Erstellen eines np.meshgrid hat nicht geholfen (nachdem die Listen in np.array konvertiert wurden).

import numpy as np 
import sys 
from mpl_toolkits.mplot3d import axes3d 
import matplotlib.pyplot as plt 
from matplotlib import cm 

filename = sys.argv[1] 

with open(filename+'.dat', 'r') as f: 
    x = [] 
    y = [] 
    z = [] 
    for line in f: 
     data = line.split() 
     x.append((float(data[0]))) 
     y.append((float(data[1]))) 
     z.append((float(data[2]))) 

zz = [627.503*(i+2134.070983645239) for i in z] 

fig = plt.figure() 
ax = fig.gca(projection='3d') 
ax.plot_trisurf(x, y, zz, cmap=cm.jet, linewidth=0.1) 
ax.dist=12 
ax.view_init(30, 45) 
ax.set_xlim(0.9, 1.9) 
ax.set_ylim(0.9, 1.9) 
ax.set_zlim(0, 170) 
plt.show() 

enter image description here

Haben Sie, bitte, alle Ideen auf, wie konnte ich die Kontur auf der x-y Ort und den Vorsprüngen auf der x-z und y-z diejenigen haben?

Antwort

1

Sie haben dreieckige Kontur und gefüllt dreieckige Kontur verwenden: tricontour und tricontourf:

fig = plt.figure() 
ax = fig.gca(projection='3d') 
ax.plot_trisurf(x, y, zz, cmap=cm.jet, linewidth=0.1) 
# projection of a surface to XY 
ax.tricontourf(x, y, zz, zdir='z', offset=-1, cmap=cm.coolwarm) 

ax.dist=12 
ax.view_init(30, 45) 
ax.set_xlim(0.9, 1.9) 
ax.set_ylim(0.9, 1.9) 
ax.set_zlim(0, 170) 
plt.show() 

enter image description here

: http://matplotlib.org/examples/pylab_examples/tricontour_demo.html

ich Ihnen Grundstück Projektion einer Oberfläche mit tricontourf XY hinzugefügt haben

+0

funktioniert einwandfrei. Prost! –