Skip to content

Scalar Quantities

Visualize scalar (real or integer)-valued data at the points of a point cloud.

Example:

import numpy as np
import polyscope as ps
ps.init()

# register a point cloud
N = 100
points = np.random.rand(N, 3)
ps_cloud = ps.register_point_cloud("my points", points)

# generate some random data per-point
vals = np.random.rand(N)

# basic visualization
ps_cloud.add_scalar_quantity("rand vals", vals)

# manually specify a range for colormapping
ps_cloud.add_scalar_quantity("rand vals with range", vals, vminmax=(-5., 5.), enabled=True)

# use a different colormap
ps_cloud.add_scalar_quantity("rand vals with range", vals, cmap='blues')

# use the 'datatype' to specify default visualization semantics
vals_gaussian = np.random.normal(size=N)
ps_cloud.add_scalar_quantity("gaussian vals symmetric", vals_gaussian, datatype='symmetric')

# view the point cloud with all of these quantities
ps.show() 

PointCloud.add_scalar_quantity(name, values, enabled=None, datatype="standard", vminmax=None, cmap=None)

Add a scalar quantity to the point cloud.

  • name string, a name for the quantity
  • values a length N numpy array, scalars at points

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

Scalar Quantity Options

When adding a scalar quantity, the following keyword options can be set. These are available for all kinds of scalar 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)
  • datatype, one of "standard", "symmetric", or "magnitude", affects default colormap and map range
  • vminmax, a 2-tuple of floats, specifying the min and max range for colormap limits; the default is None, which computes the min and max of the data
  • cmap, which colormap to use
  • isoline keywords (darker-shaded stripes showing isocontours of the scalar field):
    • isolines_enabled are isolines enabled (default: False)
    • isoline_width how wide should the darkend stripes be, in data units (default: dynamically estimated)
    • isoline_width_relative if true, interpret the width value as relative to the world coordinate length scale (default: False)
    • isoline_darkness how much darker should the alternating stripes be (default: 0.7)

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