I need to display text when mouse is over edges (similar to image). Maybe someone knows how to do it? I took the example from plotly.com and trying to modify it. It fine works for Nodes, but I can not do it for Edges.
import networkx
import plotly.graph_objects as go
G = networkx.random_geometric_graph(n=3, radius=1)
# Create Edges
edge_x, edge_y = [], []
for idx0, idx1 in G.edges():
x0, y0 = G.nodes[idx0]["pos"]
x1, y1 = G.nodes[idx1]["pos"]
edge_x.extend([x0, x1, None])
edge_y.extend([y0, y1, None])
edge_trace = go.Scatter(
x=edge_x, y=edge_y, line=dict(width=10, color='#888'), mode='lines',
hoverinfo='text', # TODO, NOT WORKING
)
# TODO, NOT WORKING
edge_trace.text = [f"# {s}" for s in edge_x]
# Create Nodes with TEXT
node_x = []
node_y = []
nodes_o = G.nodes
nodes_ids = list(nodes_o)
for node in nodes_ids:
x, y = G.nodes[node]["pos"]
node_x.append(x)
node_y.append(y)
node_trace = go.Scatter(x=node_x, y=node_y, mode="markers", hoverinfo="text",
marker=dict(color=[], size=50, line_width=10))
node_trace.text = [f"TEXT{idx}" for idx, _ in G.adjacency()]
# Create Network Graph
fig = go.Figure(
data=[edge_trace, node_trace],
layout=go.Layout(),
)
fig.show()