一 代码
import matplotlib as mplfrom mpl_toolkits.mplot3d importAxes3Dimport numpy as npimport matplotlib.pyplot as pltmpl.rcParams['legend.fontsize']=10#图例字号fig = plt.figure()ax = fig.gca(projection='3d')#三维图形theta = np.linspace(-4* np.pi,4* np.pi,100)z = np.linspace(-4,4,100)*0.3#测试数据r = z**3+1x = r * np.sin(theta)y = r * np.cos(theta)ax.plot(x, y, z, label='parametric curve')ax.legend()plt.show()
二 运行结果