|
1 | 1 | # Grandscatter |
2 | 2 |
|
3 | | -An [anywidget](https://anywidget.dev) Python package for grandscatter. |
| 3 | +Interactive multidimensional scatterplot widget for Jupyter notebooks. Rotate projection axes by dragging to explore high-dimensional point clouds with correct linear projections at all times. |
| 4 | + |
| 5 | +Built on [anywidget](https://anywidget.dev) and WebGL. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +```bash |
| 10 | +pip install grandscatter |
| 11 | +``` |
| 12 | + |
| 13 | +## Quick start |
| 14 | + |
| 15 | +```python |
| 16 | +from grandscatter import Scatter |
| 17 | +import pandas as pd |
| 18 | + |
| 19 | +df = pd.read_csv("my_data.csv") |
| 20 | + |
| 21 | +widget = Scatter( |
| 22 | + df, |
| 23 | + axis_fields=["x1", "x2", "x3", "x4", "x5"], |
| 24 | + label_field="category", |
| 25 | + label_colors={"A": "#e23838", "B": "#2196f3", "C": "#4caf50"}, |
| 26 | +) |
| 27 | +widget |
| 28 | +``` |
| 29 | + |
| 30 | +## Features |
| 31 | + |
| 32 | +- **Interactive axis rotation** -- drag axis handles to rotate the projection and explore your data from any angle. |
| 33 | +- **Orthogonal projections** -- the projection matrix is always kept orthonormal, ensuring geometrically correct linear projections. |
| 34 | +- **Perspective and orthographic modes** -- switch between projection types on the fly. |
| 35 | +- **WebGL rendering** -- fast, anti-aliased point rendering with depth sorting. |
| 36 | +- **Categorical legend** -- click legend items to highlight categories. |
| 37 | +- **Live trait sync** -- update properties like `projection`, `axis_length`, `view_angle`, and `base_point_size` from Python and see changes reflected immediately. |
| 38 | + |
| 39 | +## API |
| 40 | + |
| 41 | +### `Scatter(df, axis_fields, label_field, label_colors, **kwargs)` |
| 42 | + |
| 43 | +| Parameter | Type | Description | |
| 44 | +|---|---|---| |
| 45 | +| `df` | `pd.DataFrame` | Input data | |
| 46 | +| `axis_fields` | `list[str]` | Column names to use as projection dimensions | |
| 47 | +| `label_field` | `str` | Column name for categorical labels | |
| 48 | +| `label_colors` | `dict[str, str]` or `list[str]` | Mapping of category names to hex colors, or a list of colors in category order | |
| 49 | +| `projection` | `str` | `"orthographic"` (default) or `"perspective"` | |
| 50 | +| `axis_length` | `float` or `None` | Length of axis lines (`None` for auto) | |
| 51 | +| `camera_z` | `float` or `None` | Camera z-position for perspective mode | |
| 52 | +| `view_angle` | `float` | Field of view in degrees (default `45`) | |
| 53 | +| `base_point_size` | `float` | Point radius in pixels (default `6`) | |
| 54 | + |
| 55 | +All keyword parameters are traitlets and can be updated after creation: |
| 56 | + |
| 57 | +```python |
| 58 | +widget.projection = "perspective" |
| 59 | +widget.base_point_size = 4 |
| 60 | +widget.view_angle = 90 |
| 61 | +``` |
| 62 | + |
| 63 | +## License |
| 64 | + |
| 65 | +MIT |
0 commit comments