2016-07-26 12 views

Antwort

0

Wie wäre es, x, y, z separat zu interpolieren? Ich modifizierte this Tutorial Beispiel und hinzugefügt Interpolation es:

import matplotlib as mpl 
from mpl_toolkits.mplot3d import Axes3D 
import numpy as np 
import matplotlib.pyplot as plt 
from scipy.interpolate import InterpolatedUnivariateSpline 

mpl.rcParams['legend.fontsize'] = 10 

# let's take only 20 points for original data: 
n = 20 

fig = plt.figure() 
ax = fig.gca(projection='3d') 
theta = np.linspace(-4 * np.pi, 4 * np.pi, n) 
z = np.linspace(-2, 2, n) 
r = z**2 + 1 
x = r * np.sin(theta) 
y = r * np.cos(theta) 
ax.plot(x, y, z, label='rough curve') 

# this variable represents distance along the curve: 
t = np.arange(n) 

# now let's refine it to 100 points: 
t2 = np.linspace(t.min(), t.max(), 100) 

# interpolate vector components separately: 
x2 = InterpolatedUnivariateSpline(t, x)(t2) 
y2 = InterpolatedUnivariateSpline(t, y)(t2) 
z2 = InterpolatedUnivariateSpline(t, z)(t2) 

ax.plot(x2, y2, z2, label='interpolated curve') 

ax.legend() 
plt.show() 

Das Ergebnis sieht wie folgt aus: 3d line plot

UPDATE

Haben die Frage beim ersten Mal nicht verstehen, sorry.

Sie suchen wahrscheinlich nach einer trikubischen Interpolation. Versuchen Sie this.

+0

Vielen Dank für die Antwort. Die Verwendung der Parametrisierung ist in meinem Fall keine Option, da ich nicht weiß, wie die Parametrisierung aussehen würde ... – Odile

+0

Ja, ich dachte, Sie müssen eine Zeile interpolieren. Siehe aktualisierte Antwort. – koxy

+0

Tricubic-Interpolation ist für gleich beabstandete Koordinaten, meins sind verstreut. Wie auch immer, ich habe viele verschiedene Methoden durchgespielt, und ich denke, meine einzige Option ist eine lineare Interpolation und daher scipy.interpolate.griddata(). – Odile