0
我绘制2D曲线以代号如何通过SciPy绘制3D曲线?
c = 11
x = np.arange(0, 5, 0.1)
y = np.exp(c)/x
plt.plot(x,y)
怎样绘制一系列x,y
曲线而z轴是c
的?第一行改为
c = np.arange(1, 70, 1)
怎样绘制沿z
轴70条x,y
曲线?
我绘制2D曲线以代号如何通过SciPy绘制3D曲线?
c = 11
x = np.arange(0, 5, 0.1)
y = np.exp(c)/x
plt.plot(x,y)
怎样绘制一系列x,y
曲线而z轴是c
的?第一行改为
c = np.arange(1, 70, 1)
怎样绘制沿z
轴70条x,y
曲线?
你可以使用matplotlibs Axes3D
,教程可以发现here:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
c = np.arange(1, 10, 1) # made this 10 so that the graph is more readable
x = np.arange(0, 5, 0.1)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for i in c:
y = np.exp(i)/x
ax.plot(x, y, i)
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
plt.show()
这给图: