I understand from scouring the discourse and GitHub sites that hv.Area has issues with tooltips for the hover tool (see Hovertool on hv.Area only output questionmark · Issue #5375 · holoviz/holoviews (github.com)).
I am currently developing some tools where there are often >50 distributions to be plotted, and thus makes it difficult to identify which curve is which without useful identifying info in the tooltip. I am hoping that someone has an idea of how to add some fixed metadata for each curve in an hv.Distribution plot.
For example, how would I add a useful tooltip with info from the “ID” and “Variable” columns from the dataframe below:
import pandas as pd
import holoviews as hv
from bokeh.models import HoverTool
hv.extension('bokeh')
df = pd.DataFrame(
[np.random.choice(['ID1', 'ID2', 'ID3', 'ID4'], size=100),
np.random.uniform(0, 1, size=100)],
index = ['ID', 'value']
).T.infer_objects()
df['Variable'] = df['ID'].map({'ID1': 'x', 'ID2': 'x', 'ID3': 'y', 'ID4': 'z'})
hover = HoverTool(tooltips = [("ID", '@ID'), ("Variable", "@Variable")])
hv.Overlay(
[(i, hv.Distribution(df[df['ID']==i]['value'], label=i).opts(fill_color=c, tools=[hover])) for i, c in zip(df['ID'].unique(), ['red', 'blue', 'grey', 'purple'])]
).opts(legend_position='right', width=600, height=400)
I understand that in the code above I am only providing the values from the “value” column to hv.Distribution, hence the “???” output, but I can’t figure out how to supply additional columns to get included in the plot data so that they can be recognized by the hover tool.
If I could even just get the overlay label to show up in the tooltip, that would be sufficient for my purposes.
Thanks in advance for any help!