Skip to content Skip to sidebar Skip to footer

Python 2d Plots As 3d (matplotlib)

Python plot in Matplotlib: I have a number of samples taken daily at the same time which shows a change in measurement (of something). This may be shown as a 2D plot (below left),

Solution 1:

Would it be something like this?

from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import PolyCollection
from matplotlib.colors import colorConverter
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')

zs = [0.0, 1.0, 2.0]
t  = np.arange(1024)*1e-6
ones = np.ones(1024)
y1 = np.sin(t*2e3*np.pi) 
y2 = 0.5*y1
y3 = 0.25*y1

verts=[list(zip(t, y1)), list(zip(t, y2)), list(zip(t, y3))]


poly = PolyCollection(verts, facecolors = ['r','g','b'])
poly.set_alpha(0.7)
ax.add_collection3d(poly, zs=zs, zdir='y')
ax.set_xlabel('X')
ax.set_xlim3d(0, 1024e-6)
ax.set_ylabel('Y')
ax.set_ylim3d(-1, 3)
ax.set_zlabel('Z')
ax.set_zlim3d(-1, 1)

plt.show()

enter image description here

Post a Comment for "Python 2d Plots As 3d (matplotlib)"