Scalar Quantities
Visualize scalar valued data at the nodes or edges of a curve network.

Example:
import numpy as np
import polyscope as ps
ps.init()
# register a curve network 
N_node = 100
N_edge = 250
nodes = np.random.rand(N_node, 3)
edges = np.random.randint(0, N_node, size=(N_edge,2))
ps_net = ps.register_curve_network("my network", nodes, edges)
# visualize some random data per-node
vals_node = np.random.rand(N_node)
ps_net.add_scalar_quantity("rand vals", vals_node, enabled=True)
# visualize some random data per-edge
vals_edge = np.random.rand(N_edge)
ps_net.add_scalar_quantity("rand vals2", vals_edge, defined_on='edges')
# as always, we can customize the initial appearance
ps_net.add_scalar_quantity("rand vals2 opt", vals_edge, defined_on='edges', 
                           enabled=True, vminmax=(-3., 3.), cmap='reds')
# view the network with all of these quantities
ps.show() 
CurveNetwork.add_scalar_quantity(name, values, defined_on='nodes', enabled=None, datatype="standard", vminmax=None, cmap=None)
Add a scalar quantity to the network.
- namestring, a name for the quantity
- valuesa length- Nnumpy array, scalars at nodes/edges
- defined_onstring, one of- "nodes"or- "edges", is this data a value per-node or a value per-edge?
This function also accepts optional keyword arguments listed below, which customize the appearance and behavior of the quantity.
Categorical Scalars¶
Scalar quantities can also be used to visualize integer-valued labels such as categories, classes, segmentations, flags, etc.
Add the labels as a scalar quantity where the values just happen to be integers (each integer represents a particular class or label), and set datatype='categorical'. This will change the visualization to a different set of defaults, adjust some shading rules, and use a distinct color from the colormap for each label.
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:
- enabledboolean, 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",- "magnitude", or- "categorical", affects default colormap and map range, and the categorical policies mentioned above
- 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_enabledare isolines enabled (default:- False)
- isoline_styleone of- stripe,- 'contour(default:- stripe)
- isoline_periodhow wide should the darkend stripes be, in data units (default: dynamically estimated)
- isoline_period_relativeif true, interpret the width value as relative to the world coordinate length scale (default:- False)
- isoline_darknesshow much darker should the alternating stripes be (default:- 0.7)
- isoline_contour_thicknesshow thick should the contour lines be (default:- 0.3)
 
If not specified, these optional parameters will assume a reasonable default value, or a persistent value if previously set.