pythonjupyter-notebookbokehholoviews

customising tooltips in holoview


does anyone know how to change the hover tooltips when using holoviews with a bokeh backend?

in my notebook and using holoviews for visualisation i activate tooltips using

%%opts Scatter [tools=['hover']]

by default this makes a tooltip which displays the names of the axis and the value of the point. in bokeh you can alter the tooltip using

from bokeh.models import HoverTool
hover = HoverTool(tooltips=[
    ("index", "$index")
])

or any variation of what you want the tooltip to display. when i do this first before adding the hover tool in holoview nothing changes. does anyone know how i could change this if i dont want the default, or need to format it?


Solution

  • You can pass in a tool instance to the tools plot option, e.g. declare the tool as you have then

    from bokeh.models import HoverTool
    hover = HoverTool(tooltips=[("index", "$index")])
    

    Then use that hover tool in the options like this:

    %%opts Scatter [tools=[hover]] (size=10)
    hv.Scatter(range(10))