Построение нескольких 2D-серий в 3D (график водопада) в Matplotlib
Code source
(.env) boris@boris-All-Series:~/MATPLOTLIBSR$ cat fillBetween3D1.py
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
def plot2next3D(x,y,z):
ax.plot(x, y, zs=z, zdir='z')
col2D_obj = ax.fill_between(x, 0.5, y, step='pre', alpha=0.1)
ax.add_collection3d(col2D_obj, zs = z, zdir = 'z')
# Plot a sin curve using the x and y axes.
for z in range(0, 50, 5):
x = np.linspace(0, 1, 100)
y = z*np.sin(x * 2 * np.pi)/50/2 + 0.5
plot2next3D(x, y, z)
#ax.legend()
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.set_zlim(0, 50)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.view_init(elev=20., azim=-35)
plt.show()
No comments:
Post a Comment