Plotly interactive Multiplot is not working in Google Colab/Jupyter Notebook
Hello I'm using Google colab to display multiplot that's why I tried to create one scatterplot with 3 scatters in it and under that, there is a parallel categories plot that should be connected to scatter but when I try to select a group of points in scatter, I cannot change color in parcat it's always grey, I think those functions such as on_click and on_selection does not work but I couldn't replace them with another code can someone help me? Also tried dash but still not interactive and tried those graph in original site those not working too
https://plotly.com/python/click-events/
` import plotly.graph_objects as go from ipywidgets import widgets import pandas as pd import numpy as np
Build parcats dimensions
categorical_dimensions = ['Layer Input', 'Layer 2', 'Layer 3','Layer Output'];
dimensions = [dict(values=dfTot[label], label=label) for label in categorical_dimensions]
Build colorscale
color = np.zeros(len(dfTot), dtype='uint8') colorscale = [[0, 'gray'], [1, 'firebrick']]
Build figure as FigureWidget
fig = go.FigureWidget(
data=[
go.Scatter(x=layer_activation1[:,0], y=layer_activation1[:,1],showlegend = False,hovertemplate =y+"
"+"Cluster Groupe : "+df2['Layer 2']+"
"+"Layer 2"'
go.Scatter(x=layer_activation2[:,0], y=layer_activation2[:,1],showlegend = False,hovertemplate =y+"<br>"+"Cluster Groupe : "+df3['Layer 3']+"<br>"+"Layer 3"'<extra></extra>',
marker={'color': 'gray'}, mode='markers', selected={'marker': {'color': 'firebrick'}},
unselected={'marker': {'opacity': 0.3}}),
go.Scatter(x=layer_activation3[:,0], y=layer_activation3[:,1],showlegend = False,hovertemplate =y+"</br>"+"Cluster Groupe : "+df4['Layer Output']+"<br>"+"Layer Output"'<extra></extra>',
marker={'color': 'gray'}, mode='markers', selected={'marker': {'color': 'firebrick'}},
unselected={'marker': {'opacity': 0.3}}),
go.Parcats(
domain={'y': [0, 0.4]}, dimensions=dimensions,
line={'colorscale': colorscale, 'cmin': 0,
'cmax': 1, 'color': color, 'shape': 'hspline'})
])
fig.update_layout( height=800, xaxis={'title': 'Axis x'}, yaxis={'title': 'Axis y', 'domain': [0.6, 1]}, dragmode='lasso', hovermode='closest')
Update color callback
def update_color(trace, points, state): new_color = np.zeros(len(dfTot), dtype='uint8') # Update scatter selection fig.data[0].selectedpoints = points.point_inds new_color[points.point_inds] = 1 fig.data[3].line.color = new_color
fig.data[1].selectedpoints = points.point_inds
new_color[points.point_inds] = 1
fig.data[3].line.color = new_color
fig.data[2].selectedpoints = points.point_inds
# Update parcats colors
new_color[points.point_inds] = 1
fig.data[3].line.color = new_color
Register callback on scatter selection...
fig.data[0].on_selection(update_color) fig.data[1].on_selection(update_color) fig.data[2].on_selection(update_color)
and parcats click
fig.data[3].on_click(update_color)