ScatterWidget API#
Bases: AnyWidget
Interactive scatter drawing widget for painting multi-class 2D data points.
The widget renders a D3-powered SVG canvas where you can paint data points using a configurable brush. Points are grouped by class (color) and batch, making it easy to generate labeled 2D datasets interactively.
Examples:
Create a ScatterWidget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_classes
|
int
|
Number of point classes (1-4). Each class gets a distinct color and label. |
4
|
brushsize
|
int
|
Initial brush radius in pixels. |
40
|
width
|
int
|
SVG viewBox width in pixels. |
800
|
height
|
int
|
SVG viewBox height in pixels. |
400
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If n_classes is not between 1 and 4. |
Source code in wigglystuff/scatter_widget.py
data_as_X_y
property
#
Return the drawn points as a (X, y) tuple of numpy arrays.
When configured with n_classes=1 (regression scenario), returns
X with shape (n, 1) containing x values and y
as the target array.
When configured with n_classes>1 (classification scenario),
returns X with shape (n, 2) containing (x, y)
coordinates and y as a list of color strings.
data_as_pandas
property
#
Return the drawn points as a :class:pandas.DataFrame.
Columns: x, y, color, label, batch.
data_as_polars
property
#
Return the drawn points as a :class:polars.DataFrame.
Columns: x, y, color, label, batch.
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
data |
list[dict] |
List of drawn points with x, y, color, label, batch keys. |
brushsize |
int |
Brush radius in pixels (default: 40). |
width |
int |
SVG viewBox width in pixels (default: 800). |
height |
int |
SVG viewBox height in pixels (default: 400). |
n_classes |
int |
Number of point classes, 1-4 (default: 4). |