Question

I have two scalar fields on a 2D grid. I would like to draw a iso-line for the first scalar field an set its opacity according to the second scalar field.

I tried with mayavi starting from this SO answer but I couldn't switch from 3D to 2D.

Here's how I draw a iso line in mayavi (python).

 import numpy
 from mayavi import mlab

 x, y, z = numpy.ogrid[-5:5:64j, -5:5:64j, 0:0:1j]

 grid_x, grid_y, grid_z = numpy.mgrid[-5:5:64j, -5:5:64j, 0:0:1j]

 scalars = x*x*0.5 + y*y
 opacity = x**2
 opacity /= numpy.max(opacity) #normalize

 src = mlab.pipeline.scalar_field(grid_x,grid_y,grid_z, scalars)
 obj = mlab.pipeline.iso_surface(src, contours=[1,2,4,8,16,25,37],line_width=3)
 mlab.show()    

I don't care about how the iso lines are obtained: any scientific data visualization tool and programming language is fine. The only thing I need is being able to set the opacity of the line.

Thanks

Was it helpful?

Solution

you can set the global opacity of the line using

obj.actor.property.opacity = opacity

but opacity must be a scalar, you can't use a vector becasuse opacity is a global property of the actor

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top