Hi Plotly community!
I have just started with Plotly for python and I am already stuck
When I use a callback function (e.g. on_click) how can I distinguish between a node and a edge object?
I am using the following approach:
def update_color(trace, points, state):
# Compute new color array
new_color = np.array(fig.data.node.color)
new_color[points.point_inds] = “red”
fig.data.node.color = new_color
The problem with this approach is that the id of links and nodes overlap. Therefore, when I click on any link between nodes the id of the link is used to choose and color the node with that id. Clearly, if there are more links than nodes, than such click can also lead to an out-of-index error.
I would really appreciate your help here.