Remove 'index' in node hover information

Hello everybody,

whenever I enable the hover information (inspection_policy=nodes) on any network graph there is always per default the hover information ‘index’, which displays the node identifier.

Hovever, I do not need it because I’ve added other hover information. How can I remove it? What would work for me too is to rename ‘index’ into something else.

Do you have any idea on how to accomplish that? Any help would be appreciated.

1 Like

Hi @optmat

Could you share a minimum reproducible example? That would make it much easier to try to help and find a specific solution for your problem. Thanks.

Good idea! Thanks for looking at my question. Below a minimal reproducible example that I mostly copied from the examples in ‘Creating interaktive network graphs’
I hope this helps. If you have any other questions, please let me know.

import numpy as np
import pandas as pd
import holoviews as hv
import networkx as nx
from holoviews import opts

# some default settings 
defaults = dict(width=400, height=400)
    opts.EdgePaths(**defaults), opts.Graph(**defaults), opts.Nodes(**defaults))

# Begin creating the nodes for the graph 
N = 8
node_indices = np.arange(N, dtype=np.int32)
source = np.zeros(N, dtype=np.int32)
target = node_indices

# add node labels which should be displayed as hover node information
node_labels = ['Output']+['Input']*(N-1)

# The nodes should contain the hover information 'Label'
node_info = hv.Dataset(node_labels, vdims='Label')

# However the folloving graph contains as hover information both 'index' and 'Label'
# I would like to remove 'index'
H=hv.Graph(((source, target), node_info)).opts(node_color='Label', cmap='Set1')

# Save the Graph, "remove_index_example.html")
1 Like

`Add the following to your code:

from bokeh.models import HoverTool
hover = HoverTool(tooltips=[("label", "@Label"),])
H.opts( tools=[hover] )

Thanks a lot, that works perfectly :slight_smile: