Scaled Gaussian Points#

This example demonstrates how to plot spheres using the 'points_gaussian' style and scale them by a dynamic radius.

import numpy as np

import pyvista as pv

First, generate the sphere positions and radii randomly on the edge of a torus.

Next, create a PolyData object and add the sphere positions and radii as data arrays.

pdata = pv.PolyData(pos)
pdata['radius'] = rad

Finally, plot the spheres using the points_gaussian style and scale them by radius.

pl = pv.Plotter()
actor = pl.add_mesh(
    pdata,
    style='points_gaussian',
    emissive=False,
    render_points_as_spheres=True,
    show_scalar_bar=False,
)
actor.mapper.scale_array = 'radius'
pl.camera.zoom(1.5)
pl.show()
points gaussian scale

Show the same plot with emissive=True.

pl = pv.Plotter()
pl.background_color = 'k'
actor = pl.add_mesh(
    pdata,
    style='points_gaussian',
    emissive=True,
    render_points_as_spheres=True,
    show_scalar_bar=False,
)
actor.mapper.scale_array = 'radius'
pl.camera.zoom(1.5)
pl.show()
points gaussian scale

Total running time of the script: (0 minutes 0.600 seconds)

Gallery generated by Sphinx-Gallery