hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

Add `selector` to display sample information on hover for rasterized/datashaded plots

Open maximlt opened this issue 7 months ago • 2 comments

Resolves https://github.com/holoviz/hvplot/issues/1211

This PR introduces the selector option that exposes the similarly named selector parameter of HoloViews rasterize and datashade operations (released in HoloViews 1.21), that once set to a datashader reduction, enhances the hover tooltip with sample information selected from one of the dataset. Once enabled, the front-end tooltip needs a live kernel to display the values, as it dynamically fetches data from the server. More info in HoloViews docs https://holoviews.org/user_guide/Interactive_Hover_for_Big_Data.html.

import datashader as ds
import hvplot.pandas  # noqa
import hvsampledata

df = hvsampledata.synthetic_clusters("pandas")

plot_opts = dict(x='x', y='y', rasterize=True, data_aspect=1, frame_height=250, cnorm='log')
(
    df.hvplot.points(selector='first', title='selector="first"', **plot_opts) +
    df.hvplot.points(selector=('min', 'val'), title='selector=("min", "val")', **plot_opts) +
    df.hvplot.points(selector=ds.max('val'), title='selector=ds.max("val")', **plot_opts)
)
image

TODO:

  • [x] Only enable starting from HoloViews 1.21
  • [ ] ~~Enable by default when datashade/rasterize=True? If so, which reduction should be the default one? ds.first?~~
  • [x] Document
  • [x] Add more tests

maximlt avatar May 16 '25 17:05 maximlt

An observation, when the server/client connection is down, hovering over the plot emits a lot of error messages to the web console

[bokeh 3.7.3] not connected so cannot send Object { _buffers: Map(0), header: {…}, metadata: {}, content: {…} }
[bokeh 3.7.3] not connected so cannot send Object { _buffers: Map(0), header: {…}, metadata: {}, content: {…} }
...

maximlt avatar May 22 '25 14:05 maximlt

Enable by default when datashade/rasterize=True? If so, which reduction should be the default one? ds.first?

Meeting discussion was favoring disabling by default

droumis avatar Jun 18 '25 11:06 droumis