I am using mayavi to plot an iso surface from a 3D array s
using the following piece of code:
src = mlab.pipeline.scalar_field(s)
fig=mlab.pipeline.iso_surface(src, color=(1.0,0.0,0.0), contours=[0.1, ], opacity=0.3)
mlab.pipeline.iso_surface(src, color=(0.0,1.0,1.0),contours=[-0.1, ], opacity=0.3)
Then I want to create a plot within this iso surface representing some geometrical info regarding the isosurface, for that I use a previously defined function called geom_macro(ax)
and simply call it by typing:
geom_macro(fig)
mlab.show()
But the plot I get, although shows a good view of the isosurface it has an almost invisible plot of geom_macro()
function, which not only is size wise not comparable in any way to the iso surface, but is in an 'out of center' location (and with a diferent x,y,z saptial orientation). If I plot the two objects separately I get nice figures of both of them.
Just for completing the picture of what I have, the last part of the defined function ( geom_macro()
) looks like this ( AtPos
and Geomlst
contains the (x,y,z) coordinates of what I am plotting, and dist_btn_points
is another defined function):
for i in range (1, NCenter+1):
xp, yp, zp = AtPos[i-1][0], AtPos[i-1][1], Pos[i-1][2]
AtRadii=float(AtRadius[element[i-1]-1])
mlab.points3d(xp,yp,zp, color=AtColor[element[i-1]-1], mode='sphere',
scale_factor=AtRadii, scale_mode='none')
""" Draw connecting lines"""
for j in range(i,NCenter):
xp_c, yp_c, zp_c = AtPos[j][0], AtPos[j][1], AtPos[j][2]
xp_in, yp_in, zp_in = float(Geomlst[i-1][0]), float(Geomlst[i-1][1]), float(Geomlst[i-1][2])
xpc_in, ypc_in, zpc_in = float(Geomlst[j][0]), float(Geomlst[j][1]), float(Geomlst[j][2])
if dist_btn_pts(xp_in, yp_in, zp_in, xpc_in, ypc_in, zpc_in) < BondMax:
mlab.plot3d([xp,xp_c], [yp,yp_c], [zp,zp_c], color=(1.0,1.0,1.0), tube_radius=0.005)
I have tried changing the extent in the isosurface, using the minimum values of x, y and z, but the isosurface gets distorted -not sure why-) Any help will be highly appreciated. Thank you!