Legend entry for rasterized curve

When plotting several hv.Curves using the bokeh backend, when clicking on a legend entry, the corresponding curve gets muted, i.e., its alpha is set to 0.5, so it becomes semi-transpared and, thus, it loses highlight when compared to the unmuted ones.

I’ve followed the tutorial in the “Working with time series” section of holoviews’ user guide on Working with large data and applied holoviews.operation.datashader.rasterize on a hv.Curve, but I’m unable to get the same legend behavior as described above for regular hv.Curves. In fact, I can’t even get holoviews to show an entry for the rasterized curve in the legend.

I think I’ve read in some github issue (can’t find the ref now…) that this is somehow related to the fact that rasterize returns some sort of Image object (maybe gv.Image?).

So, the question would be, how does one go about showing a legend entry for a rasterized curve?

1 Like

Wondering if I’m seeing the same issue, as the following code doesn’t produce a legend and I don’t understand why:

import holoviews as hv
import datashader as ds
from holoviews.operation.datashader import datashade
import panel as pn
import numpy as np
import pandas as pd


# Alternative random dataframe creation
df = pd.DataFrame(np.random.randint(0, 100, size=(50000, 2)), columns=['YZF12500', 'YZF12525'])

# Create curves for each parameter
c = hv.Curve((df.index, df['YZF12500']), kdims=['Time'], vdims=['Value'])
c2 = hv.Curve((df.index, df['YZF12525']), kdims=['Time'], vdims=['Value'])

line_overlay = hv.NdOverlay({'YZF12500': c, 'YZF12525': c2}, kdims='k')
pn.serve(datashade(line_overlay, pixel_ratio=2, line_width=4, aggregator=ds.by('k', ds.count())).opts(width=800))