widgets#

class Scatter3D(coordinates, smarties=False, colors=None, hemispheres=None, z_radius=None, marker_size=5)[source]#

Bases: object

Scatter dataset for display in DataViewer.

Markers whose coordinate along the scroll axis matches the current slice are drawn at full size. When z_radius is set, markers from neighbouring slices are also drawn at reduced size to convey depth.

Parameters:
  • coordinates ((N, 3) np.ndarray or pd.DataFrame) – Point positions, or a pre-built DataFrame with columns x, y, z, colour, symbol (and optionally pen / brush). Passing a DataFrame skips the construction logic entirely.

  • smarties (bool) – Assign a pseudo-random colour to every point (ignored when colors is provided).

  • colors (array-like or None) – Per-point colours as hex strings or RGB(A) arrays. Converted to hex internally.

  • hemispheres (array-like or None) – Integer label per point that controls the marker symbol. -1 is reserved for out-of-hemisphere points, drawn with out_of_bounds_symbol.

  • z_radius (int or None) – Half-width of the depth window in slices. Points within ±*z_radius* of the current slice are drawn at a size proportional to their proximity. None / 0 disables depth display.

  • marker_size (int) – Base marker diameter in display pixels at the current slice (minimum 2).

current_slice_mask(current_slice)[source]#
get_3d_markers(main_slice_idx, z_radius=3, base_size=None)[source]#

Collect markers from slices surrounding main_slice_idx.

Marker size scales linearly with proximity: a point at distance d from the main slice gets size base_size * (z_radius - d) / z_radius.

Parameters:
  • main_slice_idx (int) – Index of the currently displayed slice.

  • z_radius (int) – Half-width of the depth window. Overridden by self.z_radius when that attribute is set.

  • base_size (int or None) – Reference size for a marker at distance 0. Pass the current UI spin-box value so surrounding markers scale consistently with the main-slice markers. Defaults to self.marker_size.

Returns

dict

Keys: 'pos' (N×2), 'size' (N,), 'symbol' (N,), and 'pen' (N,) when has_colours is True. Returns empty arrays when z_radius is falsy or no points fall in range.

get_colours(current_slice=None, indices=None)[source]#
get_draw_params(current_slice)[source]#
get_n_markers(slice_idx=None, indices=None)[source]#
get_pos(current_slice=None, indices=None)[source]#
get_symbol_sizes(main_slice_idx, slice_idx, indices=None, half_size=3)[source]#
get_symbols(current_slice)[source]#
set_data(df)[source]#
property coordinates#
property has_colours#
property has_hemispheres#
property plane_axes#
is_valid_hex_color(s)[source]#

To check if the input is a valid hex color triplet despite the lack of # at the start