Skip to content

Color Quantities

Visualize color rgb-valued data at the elements of a volume mesh.

volume mesh color values

Example: showing a color value at cells (here, random values)

# ... initialization, create mesh ...

ps_vol = ps.register_volume_mesh("test volume mesh", verts, tets=tets)

n_vert = verts.shape[0]
n_cell = tets.shape[0]

# Add a color function on cells (with some options set)
colors = np.random.rand(n_cell, 3)
ps_vol.add_color_quantity("my color", colors, defined_on='cells', enabled=True)

# Show the GUI
ps.show()

Add colors to elements

VolumeMesh.add_color_quantity(name, values, defined_on='vertices', enabled=None)

Add a scalar quantity to the network.

  • name string, a name for the quantity
  • values an Nx3 numpy array, with rgb [0,1] colors at vertices/cells
  • defined_on string, one of "vertices" or "cells", is this data a color per vertex or a color per cell?

This function also accepts optional keyword arguments listed below, which customize the appearance and behavior of the quantity.

Color Quantity Options

When adding a color quantity, the following keyword options can be set. These are available for all kinds of color quantities on all structures.

Keyword arguments:

  • enabled boolean, whether the quantity is initially enabled (note that generally only one quantitiy can be shown at a time; the most recent will be used)

If not specified, these optional parameters will assume a reasonable default value, or a persistent value if previously set.