Skip to content
Advertisement

Mayavi: How to modify the point size with points3d mode=point?

I am trying to create images like this one using Mayavi’s points3d:

enter image description here

I usually use mode="sphere", disable the lighting and adjust the size like that:

points3d(x, y, z, z,
         mode='sphere',
         scale_mode='none',
         scale_factor=0.1)

sp.actor.property.lighting = False

But for 200K points this takes several seconds to render and some more seconds to write it to disk, which is too slow if you want to do it for hundreds of images.

If I use mode="point" the image is created within a single second but the points are too small:

enter image description here

I could not find a way to enlarge the points using e.g. the approach desribed here.

Does someone have an idea if this is possible and how to do it? Or another way to speed up the process using spheres?

Advertisement

Answer

I found the solution here.

The spheres are 3D objects that consist of many triangles and rendering them is rather expensive. But it is possible to mimic the look and size of a 3D sphere (with or without lighting) with a simple circle. If you disable the lighting it looks like just like a big point and it renders very fast:

points3d(x, y, z, z,
    mode="point",
    scale_mode="none",
    scale_factor=1.0)

sp.actor.property.lighting = False
sp.actor.property.render_points_as_spheres = True
sp.actor.property.point_size = 5
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement