ParallelCoordinates API#
Bases: AnyWidget
Interactive parallel coordinates plot powered by HiPlot.
Wraps Facebook Research's HiPlot library to provide brush filtering on axes, axis reordering via drag, and coloring lines by a selected dimension -- all inside a notebook widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Dataset as a list of dictionaries, pandas DataFrame, or polars DataFrame. Each row becomes one polyline in the chart. |
None
|
color_by
|
str
|
Column name used to color lines. Leave empty for a single default color. |
''
|
color_map
|
dict[str, str] | None
|
Mapping of categorical values to CSS colors (e.g.
|
None
|
height
|
int
|
Widget height in pixels. |
500
|
width
|
int
|
Widget width in pixels. Set to 0 for container width. |
0
|
ignore
|
list[str] | None
|
Column names to exclude from the plot. |
None
|
Examples:
from wigglystuff import ParallelCoordinates
import polars as pl
df = pl.DataFrame({
"x": [1, 2, 3, 4, 5],
"y": [5, 4, 3, 2, 1],
"label": ["a", "a", "b", "b", "b"],
})
widget = ParallelCoordinates(df, color_by="label", color_map={"a": "red"})
widget
Create a ParallelCoordinates widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Dataset as a list of dicts, pandas DataFrame, or polars DataFrame. Each dict/row is one data point. |
None
|
color_by
|
str
|
Column name to color lines by. Empty string for uniform color. |
''
|
color_map
|
dict[str, str] | None
|
Mapping of categorical values to CSS colors (e.g.
|
None
|
height
|
int
|
Widget height in pixels. |
500
|
width
|
int
|
Widget width in pixels. Set to 0 for container width. |
0
|
ignore
|
list[str] | None
|
Column names to exclude from the plot. |
None
|
Source code in wigglystuff/parallel_coords.py
filtered_data
property
#
Return the subset of data rows passing all brush filters.
selected_data
property
#
Return the subset of data rows that are selected.
selections
property
#
Return the full filtering state including the active brush.
Returns a list of {"action": ..., "extents": ...} dicts.
Completed Keep/Exclude steps come first, followed by a
{"action": "current", "extents": ...} entry if there is an
active brush on any axis.
exclude #
Trigger an Exclude action on the current brush selection.
Equivalent to clicking the Exclude button in the UI. Rows inside
the current brush are removed. The action and brush extents are
recorded in :attr:filter_history.
Source code in wigglystuff/parallel_coords.py
keep #
Trigger a Keep action on the current brush selection.
Equivalent to clicking the Keep button in the UI. Rows outside
the current brush are removed. The action and brush extents are
recorded in :attr:filter_history.
Source code in wigglystuff/parallel_coords.py
restore #
Restore all rows and clear the filter history.
Equivalent to clicking the Restore button in the UI. All
Keep/Exclude operations are undone and :attr:filter_history
is reset to an empty list.
Source code in wigglystuff/parallel_coords.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
data |
list[dict] |
Input rows rendered as polylines. |
color_by |
str |
Column used for line coloring. |
color_map |
dict |
Map of categorical values to CSS colors (e.g. {"a": "red", "b": "#00f"}). Unmapped values use the default palette. |
height |
int |
Plot height in pixels. |
width |
int |
Plot width in pixels. Set to 0 for container width. |
brush_extents |
dict |
Current brush ranges on axes. Resets to {} after Keep/Exclude. |
filtered_indices |
list[int] |
Indices currently passing filters/selection. |
selected_indices |
list[int] |
Indices currently selected in the active brush. |
Methods#
| Method | Description |
|---|---|
selections |
Property returning filter_history + a trailing {"action": "current", "extents": ...} entry for the active brush (if any). |
keep() |
Trigger a Keep action on the current brush selection (same as the Keep button). |
exclude() |
Trigger an Exclude action on the current brush selection (same as the Exclude button). |
restore() |
Restore all rows and clear filter_history (same as the Restore button). |
filtered_data |
Property returning the list of dicts for rows passing all filters. |
filtered_as_pandas |
Property returning filtered data as a pandas DataFrame. |
filtered_as_polars |
Property returning filtered data as a polars DataFrame. |
selected_data |
Property returning the list of dicts for selected rows. |