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

用Python在三维图上标注特定点的坐标,第1张

用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")

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5720848.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存