/ / Stapel von 2D-Plot - Python, Matplotlib

Stapel von 2D-Plot - Python, Matplotlib

Ich versuche, gestapelte 2D sin (Omega t) für 0 <= t <= 2 pi mit verschiedenen Omega-Werten als 3D-Plot mit Python und Matplotlib zu plotten. Jeder Hinweis wird geschätzt.

(etwas wie dieses)

So etwas wie dieses

Antworten:

4 für die Antwort № 1

Dies kann mit dem einfachen erfolgen Befehl plotten:

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

NANGLES = 200

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
nvals = [0, 2, 4, 10, 20, 40, 100]
for iy in range(len(nvals)):
n = nvals[iy]
x = np.arange(NANGLES) / float(NANGLES)
y = np.ones(NANGLES)*iy # set y position to same value, with regular step
z = np.sin(n*x*np.pi)
ax.plot(x, y, z)
ax.set_ylabel("n")
ax.set_yticklabels(nvals) # update y ticks (set at regular step) to your vals

plt.savefig("stackedplot.png")
plt.show()

Was ich gezeigt habe, ist ein einfacher Start, und die Anpassung der kosmetischen Aspekte der Handlung ist wahrscheinlich eine gute Herausforderung, um mehr von python / matplotlib zu lernen:

Bildbeschreibung hier eingeben