mayavi是否可以单独指定每个点的大小和颜色?
那个API对我来说很麻烦.
points3d(x, y, z...)
points3d(x, y, z, s, ...)
points3d(x, y, z, f, ...)
x, y and z are numpy arrays, or lists, all of the same shape, giving the positions of the points.
If only 3 arrays x, y, z are given, all the points are drawn with the same size and color.
In addition, you can pass a fourth array s of the same shape as x, y, and z giving an associated scalar value for each …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用mayavi.mlab注释使用points3d()函数绘制的点.每个点都与一个标签相关联,我希望使用text3d()函数在点旁边绘制标签.绘制点很快,但是mlab.text3d()函数似乎不接受坐标数组,所以我必须循环遍历点并单独绘制文本,这非常慢:
for i in xrange(0, self.n_labels):
self.mlab_data.append(
mlab.points3d( pX[self.labels == self.u_labels[i], 0],
pX[self.labels == self.u_labels[i], 1],
pX[self.labels == self.u_labels[i], 2],
color=self.colours[i],
opacity=1,
scale_mode="none",
scale_factor=sf ) )
idcs, = np.where(self.labels == self.u_labels[i])
for n in idcs.flatten():
mlab.text3d( pX[n, 0],
pX[n, 1],
pX[n, 2],
"%d" % self.u_labels[i],
color=self.colours[i],
opacity=1,
scale=sf )
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以加快速度吗?此外,是否可以添加图例(例如在matplotlib中),我在文档中找不到任何内容.
谢谢,
帕特里克