import numpy as npfrom matplotlib import pyplot as pltfig = plt.figure()ax = plt.axes(projection="3d")x = y = np.arange(start=-1, stop=1, step=0.05)X, Y = np.meshgrid(x, y)Z = (X-Y)*(X+Y)ax.plot_surface(X,Y,Z,alpha=0.8, cstride=1, rstride = 1, cmap='rainbow')X=0.5Y=0.9Z=(X-Y)*(X+Y)ax.scatter(X,Y,Z,c="r")X=[0.5,0.5]Y=[0.9,0.9]Z=[-1,-0.5999999999]ax.plot(X,Y,Z,'r--')X=[0.5,0.5]Y=[-1,0.9]Z=[-1,-1]ax.plot(X,Y,Z,'r--')X=[0.5,1]Y=[0.9,0.9]Z=[-1,-1]ax.plot(X,Y,Z,'r--')ax.text(0.4,0.7,-0.4,'-0.5999')plt.show()fig.savefig("3d.jpg")
用Python在三维图上标注特定点的坐标
时间:2023-08-25
相关推荐