ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

python – 具有不同大小和颜色的Mayavi points3d

2019-10-07 14:56:03  阅读:260  来源: 互联网

标签:vtk mayavi python data-visualization


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 point, or a function f(x, y, z) returning the scalar value. This scalar value can be used to modulate the color and the size of the points.

因此,在这种情况下,标量控制大小和颜色,并且不可能解开它们.我想要一种方法将大小指定为(N,1)数组,并将颜色指定为另一个(N,1)数组.

看起来很复杂?

解决方法:

每个VTK源都有一个标量和向量的数据集.

我在我的程序中使用的技巧是使颜色和大小不同是绕过mayavi源并直接在VTK源中,使用标量颜色和矢量大小(它可能反过来也适用).

nodes = points3d(x,y,z)
nodes.glyph.scale_mode = 'scale_by_vector'

#this sets the vectors to be a 3x5000 vector showing some random scalars
nodes.mlab_source.dataset.point_data.vectors = np.tile( np.random.random((5000,)), (3,1))

nodes.mlab_source.dataset.point_data.scalars = np.random.random((5000,))

您可能需要转置5000×3矢量数据或以其他方式移动矩阵尺寸.

标签:vtk,mayavi,python,data-visualization
来源: https://codeday.me/bug/20191007/1867518.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有