A scatter plot extension for Jupyter Notebook and Lab
Project description
jupyter-scatter
A scalable scatter plot extension for Jupyter Lab and Notebook
Why? After embedding data we want to explore the embedding space, which typically involves three things besides plotting the data as a 2D scatter. First, we want to interactively adjust the view (e.g., via panning & zooming) and the visual point encoding (e.g., the point color, opacity, or size). Second, we want to be able to select/highlight points. And third, we want to compare multiple embeddings (e.g., via animation, color, or point connections). The goal of jscatter is to support all three requirements and scale to millions of points.
How? Internally, jupyter-scatter is using regl-scatterplot for rendering and ipywidgets for linking the scatter plot to the iPython kernel.
Install
pip install jupyter-scatter
Getting Started
import jscatter
import numpy as np
# Let's generate some dummy data
points = np.random.rand(500, 2)
values = np.random.rand(500) # optional
categories = (np.random.rand(500) * 10).astype(int) # optional
# Let's plot the data
scatterplot = jscatter.plot(points, categories, values)
scatterplot.show()
To adjust the scatter plot interactively let's pull up some options:
scatterplot.options()
Finally, to retrieve the current selection of points (or programmatically select points) you can work with:
scatterplot.selected_points
For a complete example, take a look at notebooks/example.ipynb
Development
Requirements:
- Conda >= 4.8
Installation:
git clone https://github.com/flekschas/jupyter-scatter/ jscatter && cd jscatter
conda env create -f environment.yml && conda activate jscatter
pip install -e .
Enable the Notebook Extension:
jupyter nbextension install --py --symlink --sys-prefix jscatter
jupyter nbextension enable --py --sys-prefix jscatter
Enable the Lab Extension:
jupyter labextension develop --overwrite jscatter
After Changing Python code: simply restart the kernel.
After Changing JavaScript code: do cd js && npm run build
and reload the browser tab.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jupyter_scatter-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1b78f5abaa708aaa222d3b23e26c94fd050227945f85b0d47dfaeee1444cf35 |
|
MD5 | d53e3f3ae90ddf9522f4d8919bdb610f |
|
BLAKE2b-256 | 6ac12a96a8eb9104073f32f1bd3b09a0340d7f55e70680c7c5925d4b0fa44483 |