points#
- k3d.factory.points(positions, colors=[], color=255, point_size=1.0, point_sizes=[], shader='3dSpecular', opacity=1.0, opacities=[], attribute=[], color_map=None, color_range=[], opacity_function=[], name=None, group=None, custom_data=None, compression_level=0, mesh_detail=2, **kwargs)[source]#
Create a Points drawable representing a point cloud.
- Parameters
positions (array_like) – Array of (x, y, z) coordinates.
colors (list, optional) – Array of Hex colors, by default [].
color (int, optional) – Hex color of the points when colors is empty, by default _default_color.
point_size (float, optional) – Diameter of the points, by default 1.0.
point_sizes (list, optional) – Same-length array of float sizes of the points, by default [].
shader ({'flat', 'dot', '3d', '3dSpecular', 'mesh'}, optional) – Display style of the points, by default “3dSpecular”.
opacity (float, optional) – Opacity of points, by default 1.0.
opacities (list, optional) – Same-length array of float opacity of the points, by default [].
attribute (list, optional) – List of values used to apply color_map, by default [].
color_map (list, optional) – List of float quadruplets (attribute value, R, G, B) sorted by attribute value, by default None. The first quadruplet should have value 0.0, the last 1.0; R, G, B are RGB color components in the range 0.0 to 1.0.
color_range (list, optional) – [min_value, max_value] pair determining the levels of color attribute mapped to 0 and 1 in the colormap, by default [].
opacity_function (list, optional) – float tuples (attribute value, opacity) sorted by attribute value, by default []. The first tuples should have value 0.0, the last 1.0; opacity is in the range 0.0 to 1.0.
name (str, optional) – Object name, by default None.
group (str, optional) – Name of a group, by default None.
compression_level (int, optional) – Level of data compression [-1, 9], by default 0.
custom_data (dict) – A object with custom data attached to object.
mesh_detail (int, optional) – Detail level of points mesh, by default 2. Only valid if shader is set to mesh. Setting this to a value greater than 0 adds more vertices making it no longer an icosahedron. When detail is greater than 1, it’s effectively a sphere.
**kwargs – For other keyword-only arguments, see process_transform_arguments.
- Returns
Points Drawable.
- Return type
Points
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()