points#

k3d.factory.points(positions: List | ndarray | Tuple, colors: List[int] = None, color: int = 255, point_size: float = 1.0, point_sizes: List | ndarray | Tuple = None, shininess: float = 50.0, shader: str = '3dSpecular', opacity: float = 1.0, opacities: List | ndarray | Tuple = None, attribute: List | ndarray | Tuple = None, color_map: List[List[float]] | Dict[str, Any] | ndarray | None = None, color_range: List[float] = None, opacity_function: List[float] = None, name: str | None = None, group: str | None = None, custom_data: Dict[str, Any] | None = None, compression_level: int = 0, mesh_detail: int = 2, **kwargs: Any) Points[source]#

Examples#

Basic#

import k3d
import numpy as np

x = np.random.randn(1000,3).astype(np.float32)

plt_points = k3d.points(positions=x,
                        point_size=0.2,
                        shader='3d',
                        color=0x3f6bc5)

plot = k3d.plot()
plot += plt_points
plot.display()

Colormap#

Attention

color_map must be used along with attribute and color_range in order to work correctly.

import k3d
import numpy as np
from k3d.colormaps import matplotlib_color_maps

x = np.random.randn(10000, 3).astype(np.float32)
f = (np.sum(x ** 3 - .1 * x ** 2, axis=1))

plt_points = k3d.points(positions=x,
                        point_size=0.1,
                        shader='flat',
                        opacity=0.7,
                        color_map=matplotlib_color_maps.Coolwarm,
                        attribute=f,
                        color_range=[-2, 1])

plot = k3d.plot()
plot += plt_points
plot.display()