Peeling off the layers#

This example uses thresholds to select two different ranges of values in the data, and display them on the same scatter plot using a lower opacity for the outer layer, revealing the inside of the clusters.

[1]:
import plopp as pp
import scipp as sc
import numpy as np

We first generate some fake data, meant to represent clusters of points in a three-dimensional space.

The data values scale with \(1/r^{2}\) where \(r\) is the distance to the center of each cluster.

[2]:
from plopp.data.examples import clusters3d

da = clusters3d()

We select two data ranges (high values and low values), and display both at the same time, lowering the opacity of the low-value data range.

[3]:
# Select ranges
a = da[da.data > sc.scalar(0.05)]
b = da[(da.data > sc.scalar(0.002)) & (da.data < sc.scalar(0.005))]

# Display both on the same scatter plot
p = pp.scatter3d({'a': a, 'b': b}, pos='position', norm='log')

# Extract the point clouds from the final plot and set a lower opacity on the second point cloud
clouds = list(p.artists.values())
clouds[1].opacity = 0.1

p
[3]: