Jupyter Scatter gets support for text labels

New version of Jupyter Scatter is out! 🄳 Adding long-overdue support for text labels that make it easier to correlate points with your underlying data.

Designing a generic DataFrame-driven method that integrates with Jupyter Scatter’s overall API design was a fun challenge. I ended up modeling the label assignment via categorical/string columns, which groups points and shows a single text label per group. Point labels are also supported and you can assign as many label types as you need.

To learn how to use the new labeling feature see:

The label placement is implemented using a dynamic map labeling approach to avoid over-plotting while maximizing the labels that can be shown across zoom levels. Label positions are computed upfront for performant rendering and can be persisted as parquet files for fast re-use. Additionally, the label data is tiled to allow limiting the total number of labels per tile and enable scaling to hundreds of thousands of labels.

Some fantastic libraries I learned about and use for labeling:

  • Jeffrey Heer’s Flechette is a fast and lightweight library for loading Apache Arrow. Jupyter Scatter uses it to send label information between Python <> JS kernels as binary data. Flechette is perfect for this! Really nice work Jeff. šŸ‘
  • Kyle Barron’s geoindex is a fast, memory-efficient, zero-copy spatial indexing library for Python. Essentially the counterpart to Volodymyr Agafonkin’s fantastic KDBush which we’re using under the hood in regl-scatterplot already for statically indexing 2D points. šŸ™Œ
  • Rye Terrell’s awesomeCandygraph library for plotting 2D charts with WebGL heavily inspired our text measurement implementation. Efficiently and precisely measuring the labels’ dimensions is critical for handling many text labels. šŸ‘
  • Thilo Spinner’s Colormap 2D is a library implementing various 2D color maps from Steiger et al.’s (2015) ā€œExplorative analysis of 2D color mapsā€. 2D color maps are an excellent way to color points in data maps with many categories/groups/labels. šŸ™Œ

Finally, shoutouts to Trevor Manz for reviewing the quite involved PR and Leland McInnes’ wonderful DataMapPlot library which inspired the 2D color map integration and has many excellent shared examples. šŸ™

Let me know what you think and happy scatter plot labeling šŸ·ļø