holoviz / hvplot

A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews
https://hvplot.holoviz.org
BSD 3-Clause "New" or "Revised" License
1.02k stars 99 forks source link

Automatically enable 'instant' inspection at the `hvplot` level #1211

Open droumis opened 7 months ago

droumis commented 7 months ago

When HoloViews supports Datashader inspections, it will still need to be enabled: at the very minimum you will need to apply the inspect operation appropriately.

However, at the hvPlot level, it would be appropriate to automatically configure this for you when switching to a datashaded/rasterized plot. The goal would be for datashaded plots to have all the same affordances and behaviors of normal Bokeh glyphs from the user perspective.

Technically, hvPlot should automate the generation of index layers or additional aggregate arrays so both index-based and non-index-based inspections just work.

This should include new documentation in hvPlot.

JLS note: One thing to note is that enabling instant inspection with some random sample (e.g first) could be an easy default but you probably want to have an API to allow hvplot to specify where aggregations instead (e.g. 'show the longest ship').

maximlt commented 7 months ago

When HoloViews supports Datashader inspections

I'm a bit confused, HoloViews already has some support for datashader inspections? I see inspect_points and inspect_polygons in its code base at least.

This should include new documentation in hvPlot.

As far as I can see, inspection isn't yet documented in HoloViews. I'd say it should be documented in HoloViews first, before adding documentation in hvPlot (that should link to HoloViews).

philippjfr commented 7 months ago

I'm a bit confused, HoloViews already has some support for datashader inspections? I see inspect_points and inspect_polygons in its code base at least.

These are very crude implementations and cover a tiny fraction of what we want to support. In fact they should go away entirely and we should automatically generate the inspection behavior that makes the most sense given the data. While a lot of the automatic rendering of the inspection information will happen in HoloViews, the automatic generation of the necessary inspection data will likely be left to hvPlot (with more manual steps being required at the HoloViews level). So the documentation at the hvPlot and HoloViews level will be largely independent.

See the Datashader Inspections project for the full vision. The high-level summary is that we want to support two types of inspections (and the inspect operations` in HoloViews right now are a very crude implementation of the the index based inspections).

Index based inspection

Description: When you rasterize you create two aggregates, one with the actual rendered data and one containing indexes of the first N data points in a particular pixel. When the user hovers over the pixel we send an event back to Python that requests hover information about that location. We then send back a Tooltip with the information about that pixel.

Non-index based selection

Description: When rasterizing a categorical plot or providing multiple aggregators you can end up with an Image(Stack) that contains not just the layers for the image to be rendered but additional layers containing information that can be revealed client-side in the standard HoverTool.

droumis commented 6 months ago

Here's a more direct link to the draft issue containing the full Datashader inspections goal.

Also, the board shows there are several things to do before implementing in hvPlot. I estimated a target of April 2024 TBD for this.