python – 具有不同大小和颜色的Mayavi points3d
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python – 具有不同大小和颜色的Mayavi points3d,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1234字,纯文字阅读大概需要2分钟。
内容图文
![python – 具有不同大小和颜色的Mayavi points3d](/upload/InfoBanner/zyjiaocheng/698/ea307dfe444c4a69a58af2da7c91c647.jpg)
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矢量数据或以其他方式移动矩阵尺寸.
内容总结
以上是互联网集市为您收集整理的python – 具有不同大小和颜色的Mayavi points3d全部内容,希望文章能够帮你解决python – 具有不同大小和颜色的Mayavi points3d所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。