简体   繁体   English

具有多个半径的单线与 Mayavi

[英]Single line with multiple radii with Mayavi

I am trying to plot a single line (or tube) in Mayavi that has a non-constant width or radius.我试图在 Mayavi 中绘制一条宽度或半径不恒定的线(或管)。 This seems like a simple task though I may not be understanding what is happening behind the scenes well enough to make this happen.这似乎是一项简单的任务,尽管我可能无法很好地理解幕后发生的事情来实现这一目标。

The following code creates the line I want, and I am able to scale by color;下面的代码创建了我想要的线条,我可以按颜色缩放; however, I would also like to scale by width.但是,我也想按宽度缩放。

import mayavi.mlab as mlab
import numpy as np

x = range(100)
y = range(100)
z = range(100)
s = np.random.uniform(0, 1, 100)

mlab.plot3d(x, y, z, s, tube_radius=10)

在此处输入图片说明

I don't have an image of the desired output as I am unable to create it, though it would essentially be the preceding image scaled by radius instead of color, so that some areas of the line would be wider than other areas.我没有所需输出的图像,因为我无法创建它,尽管它本质上是按半径而不是颜色缩放的前一个图像,因此线条的某些区域会比其他区域更宽。 One possible solution would be to use the tube_radius parameter and plot each section individually, though this really seems like poor practice as the lines can get quite long and have many different sections.一种可能的解决方案是使用tube_radius参数并单独绘制每个部分,尽管这看起来确实很糟糕,因为线条可能会变得很长并且有许多不同的部分。

In the GUI, you can go to the Tube pipeline and use Vary_radius = 'vary_radius_by_scalar'在 GUI 中,您可以转到Tube管道并使用Vary_radius = 'vary_radius_by_scalar'

In the script you can do在脚本中你可以做

import mayavi.mlab as mlab
import numpy as np

x = range(100)
y = range(100)
z = range(100)
s = np.random.uniform(0, 1, 100)

t = mlab.plot3d(x, y, z, s, tube_radius=10)
t.parent.parent.filter.vary_radius = 'vary_radius_by_scalar'

Since the parent of the surface is the Module manager (colors, etc) and its parent is the Tube pipeline由于表面的父级是模块管理器(颜色等),而其父级是Tube管道

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM