I am trying to visualize a social network using Cytoscape in Dash. I would like each node to be automatically colored based on the number of followers that node has. The current documentation for Cytoscape shows how to do this with classes for a very limited number of classes. But I would like to find a way to translate how this is done in normal Plotly with a colorscale into my network graph.
For the data, I have my element list with the nodes containing the following format:
[{'data': {'id': 'id1',
'label': 'label1',
'name': 'name1',
'weight': 0.3}
...
{'data': {'id': 'idN',
'label': 'labelN',
'name': 'nameN',
'weight': 0.8}]
I have tried reading in the weight as a scaling in a few different places, but the place that made the most sense was to do it was in the default_stylesheet
(showing with background-opacity
, but I really would prefer to do this is a colorscale) as
default_stylesheet = [
{
'selector': 'node',
'style': {
'background-color': '#2722AF',
'background-opacity': 'data(weight)'
}
},
{
'selector': 'edge',
'style': {
'line-color': '#cfd1d3',
'opacity': 0.3,
'width': 1
}
}
]
However, when I do this I get Error loading layout
in my browser.
Any tips would be greatly appreciated! Thank you!