I am trying to link three different plot using link selection. I was able to successfully link the scatter plots, but I could not figure out how to link the networkx graph. I have attached my code below and if anyone can provide some information, please let me know.
def neo4j_to_dataframe(self, results):
nodes = {}
relationships = {}
for result in results:
n = result.get('n',None)
if n is not None and n.element_id not in nodes:
node_data = dict(n.items())
element_id = n.element_id
node_data['element_id'] = element_id
nodes[element_id] = node_data
m = result.get('m',None)
if m is not None and m.element_id not in nodes:
node_data = dict(m.items())
element_id = m.element_id
node_data['element_id'] = element_id
nodes[element_id] = node_data
r = result.get('r', None)
print(r)
if r is not None and r.element_id not in relationships:
relationship_data = {}
relationship_data['type'] = result['r'].type
relationship_data['element_id'] = r.element_id
relationship_data['start_node'] = r.nodes[0].element_id
relationship_data['end_node'] = r.nodes[1].element_id
relationships[r.element_id] = (relationship_data)
nodes = list(nodes.values())
relationships = list(relationships.values())
nodes = pd.DataFrame(nodes)
relationships = pd.DataFrame(relationships)
return nodes, relationships
pos = graphviz_layout(graph, prog="twopi")
hv_graph = hv.Graph.from_networkx(graph, pos)
hv_graph.opts(opts.Graph(node_size=8,edge_line_width=1,node_fill_color='color', width=400,height=400,inspection_policy='nodes',title='Neo4j Graph Visualization',))
nodes_df.set_index("element_id", inplace=True)
relationship_df.set_index("element_id", inplace=True)
scatter_plot_1 = nodes_df.hvplot.points(x='columnA', y='columnB', width=500)
scatter_plot_2 = nodes_df.hvplot.points(x='columnC', y='columnD', width=500)
ls = hv.link_selections.instance()
ls(scatter_plot_1 + scatter_plot_2 + hv_graph)
The two scatter plots are linked and I can select different points on the graph and I can see the related points, but the highlighting is not working with graph.