zeus300
zeus300

Reputation: 1075

Mayavi mesh with common color scheme

I am plotting two mayavi meshes in the same figure. I'm supplying surface vertex scalars to guide the coloring. It seems that mayavi uses a per-mesh color scale. What I would like, however, is a commonized color scale, so that the cube I draw with these six meshes, for example

mlab.mesh(x_0, y_0, z_0, scalars=1 * np.ones_like(x_0), colormap='jet')
mlab.mesh(x_1, y_1, z_1, scalars=2 * np.ones_like(x_0), colormap='jet')
mlab.mesh(x_2, y_2, z_2, scalars=3 * np.ones_like(y_0), colormap='jet')
mlab.mesh(x_3, y_3, z_3, scalars=4 * np.ones_like(y_0), colormap='jet')
mlab.mesh(x_4, y_4, z_4, scalars=5 * np.ones_like(z_0), colormap='jet')
mlab.mesh(x_5, y_5, z_5, scalars=6 * np.ones_like(z_0), colormap='jet')

doesn't turn out all dark blue for each face.

I'm trying to visualize a 3D scalar field on the surface of a cuboid, but the colors don't match up at the edges/corners. Can't find anything in the documentation.

The common color scaling doesn't necessarily have to be automatic. If there was a way to set the lower and upper value limit for each map like with clim in matplotlib, I could set that the same for all mesh commands.

Upvotes: 0

Views: 1106

Answers (1)

zeus300
zeus300

Reputation: 1075

Finally found it documented for another function, but mlab.mesh also understands the parameters vmin and vmax that determine the lower and upper level to use for the color scale, so above calls would be:

mlab.mesh(x_0, y_0, z_0, scalars=1 * np.ones_like(x_0), colormap='jet', vmin=0, vmax=1)

Upvotes: 2

Related Questions