python - 使用 Axes3D.plot_wireframe 和 Axes3D.scatter 绘图:线框隐藏的散点
问题描述
我使用 绘制圆盘的离散表面,并在同一张图上使用(附图)Axes3d.plot_wireframe
叠加对应于圆盘中心的点。Axes3d.scatter
我的问题是只有在配置文件中看到光盘时才能看到该点。无论视图如何,我都希望它可见。我也加入了我的脚本的一部分(抱歉,如果它没有按应有的方式出现)。
我尝试更改脚本中绘图的顺序,尝试'zorder'
在两个绘图中添加一个参数,并且我还尝试更改散点图中的标记大小,但它不起作用。
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import pylab as plt
import numpy as np
# data to build the disc
r = np.linspace(0, 5e-3, 30)
psi = np.linspace(0, 2*np.pi, 30)
n = np.array([0.70710678, 0, 0.70710678])
e2 = np.array([0.70710678, 0, -0.70710678])
e3 = np.array([0, 1, 0])
Oc = np.array([0, 0, 0])
R, PSI = np.meshgrid(r, psi)
OpP = np.zeros((len(r),len(psi),3), dtype=float)
OpP[:,:,0] = np.zeros((len(r),len(psi)), dtype=float)
OpP[:,:,1] = R*np.cos(PSI)
OpP[:,:,2] = R*np.sin(PSI)
Mrot = np.zeros((3,3), dtype=float)
Mrot[0,:] = n
Mrot[1,:] = e2
Mrot[2,:] = e3
Ocx = Oc[0]; Ocy = Oc[1]; Ocz = Oc[2]
xp = Ocx + np.dot(OpP, Mrot)[:,:,0]
yp = Ocy + np.dot(OpP, Mrot)[:,:,1]
zp = Ocz + np.dot(OpP, Mrot)[:,:,2]
# Plotting
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_wireframe(zp,yp,xp, label='piston')
ax.scatter(Ocz, Ocy, Ocx, zdir='z', s=40, color='red', label='Oc')
plt.gca().invert_yaxis()
plt.legend()
plt.show()
解决方案
推荐阅读
- python - 可以使用第一个函数访问另一个函数内的函数内声明的列表,但不使用全局属性就不能访问变量
- python - 如何在 Docker 容器中运行 pdb
- php - 在一行中显示多行
- python - 这个批处理 FOR 命令如何转换为 python?
- python - 如何在数据框中显示所有列内容
- angular - 如何在没有角度的其他网站上使用量角器进行 E2E 测试?
- python - 您可以在 SQL SERVER 2016 中将 Python 与 MS 机器学习一起使用吗
- postgresql - Postgres 在使用 OR 过滤器时使用低效的查询计划,在使用 IN 子句时使用正确的索引
- vb.net - 我需要查看什么来解决此打印问题
- c - 如果人多于一,求每个人的最高值和最低值