I’m a bit new to datashader and interactive plots with Holoviews and Bokeh. In the census example, I am trying to figure out if we can customize the hover tool to show race with easting and northling. I modified this line to add in opts(tools[‘hover’]):
points = hv.Points(gv.Dataset(df, kdims=[‘easting’, ‘northing’], vdims=[‘race’]))
race = dynspread(datashade(points, color_key=color_key, element_type=gv.Image, aggregator=ds.count_cat(‘race’)).opts(tools=[‘hover’]))
gts.OSM() * race
however I only get the default eastling, northling coordinates along with RGBA. I would like to see race also. I have tried to mimic the census example with my own datasets and with the HoverTool, don’t seem to get past only displaying the x,y Points that we hand to datashader.
[Edited to reflect actually trying it out and opening an issue about it on HoloViews]
datashade operation turns the provided points into an RGB image with two spatial dimensions (easting and northing) plus the RGB color dimensions; the “race” is no longer available for hovering (or anything except rendering to the screen) at that point. (It’s just an array of RGB pixels!)
Usually, you can solve such problems by switching to use
rasterize, which makes Datashader return the raw arrays to Bokeh and HoloViews instead of rendering the arrays as RGB and then returning the RGB image. However, for a categorical plot like this one, the raw array returned by Datashader is actually a stack of arrays, one per race, which
rasterize turns into an NdOverlay. Unfortunately, currently only the top layer of that overlay is shown in hovering. I’ve opened an issue https://github.com/holoviz/holoviews/issues/4236 .