用Python在三维图上标注特定点的坐标

import numpy as np
from matplotlib import pyplot as plt
fig = 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.5
Y=0.9
Z=(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在三维图上标注特定点的坐标_第1张图片

你可能感兴趣的:(python,matplotlib)