【发布时间】:2022-09-28 21:01:07
【问题描述】:
我正在使用mayavi.mlab.mesh 绘制一个带有与之关联的标量场的球体。鉴于该球体上的一些坐标,我还想绘制点与该点的网格表面颜色相同.
例如:
import numpy as np
from mayavi import mlab
# Here I construct the spherical mesh grid
phi = np.linspace(0, np.pi, 100)
theta = np.linspace(0, 2*np.pi, 100)
phi, theta = np.meshgrid(phi, theta)
x = (np.sin(phi) * np.cos(theta)).astype(np.float32)
y = (np.sin(phi) * np.sin(theta)).astype(np.float32)
z = (np.cos(phi)).astype(np.float32)
# Let\'s use a random scalar field to demonstrate
s = np.random.randn(*x.shape)
# Now we plot the sphere surface
plot = mlab.mesh(x, y, z, scalars=s, colormap=\'jet\')
# Let\'s create some random points on the sphere that we want to additionally
# plot as mlab.points3d
pts = np.random.randn(10, 3)
pts = pts / np.linalg.norm(pts)
我想用与下面的网格表面相同的颜色绘制pts,但我不确定该怎么做。
标签: python mayavi mayavi.mlab