@ch3njus Your data list contains 11 scatter traces of mode='markers+lines'
. It seems that such a trace defines a group of nodes and edges.
For example data[2] is defined as follows:
Scatter({
'hoverinfo': 'text',
'line': {'color': 'rgb(210,210,210)', 'width': 2},
'marker': {'color': [rgb(0,0,0), rgb(0,255,0), rgb(255,0,0)],
'line': {'color': [rgb(0,0,0), rgb(0,255,0), rgb(255,0,0)], 'width': 8},
'size': 5,
'symbol': 'circle'},
'mode': 'lines+markers',
'name': 'hdsgd',
'text': [smpl-0, smpl-2, smpl-1],
'x': [2.8060800255, 3.44368272156, None, 3.44368272156, 2.8060800255, None,
1.91853539044, 2.8060800255, None, 2.8060800255, 1.91853539044, None],
'y': [-0.282090636501, -1.11656787037, None, -1.11656787037, -0.282090636501,
None, 0.283726548186, -0.282090636501, None, -0.282090636501,
0.283726548186, None]
})
Copying the x, y coordinates we can notice that each node and edge is is inserted into the list multiple times. Why?
xx=[2.8060800255, 3.44368272156, None, 3.44368272156, 2.8060800255, None,
1.91853539044, 2.8060800255, None, 2.8060800255, 1.91853539044, None]
yy=[-0.282090636501, -1.11656787037, None, -1.11656787037, -0.282090636501,
None, 0.283726548186, -0.282090636501, None, -0.282090636501,
0.283726548186, None]
list(zip(xx,yy))
[(2.8060800255, -0.282090636501), #point-1
(3.44368272156, -1.11656787037), #point-2
(None, None),
(3.44368272156, -1.11656787037), #point-2
(2.8060800255, -0.282090636501), #point-1
(None, None),
(1.91853539044, 0.283726548186), #point-3
(2.8060800255, -0.282090636501), #point-1
(None, None),
(2.8060800255, -0.282090636501), #point-1
(1.91853539044, 0.283726548186), #point-3
(None, None)]
Let us plot the plotly figure having its data member consisting in just this trace:
import plotly.graph_objs as go
layout=dict(width=500, height=500, xaxis=dict(visible=False), yaxis=dict(visible=False), hovermode='closest')
fw=go.FigureWidget(data=[data[2]], layout=layout)
fw
We get this plot:
![graph-plot](https://us1.discourse-cdn.com/flex020/uploads/plot/original/2X/3/3366d8f841141814002b4d3226c5c2e13df1235c.jpeg)
All three nodes have the same color and perhaps you expected to be colored with black, red, respectively green.
Why are they plotted in this way? Because the list data[2].marker.color
,of color codes, hasn’t the same length (12) as the lists of x and y-coordinates.
The association point-->color
in data[2]
trace was performed as follows:
[(2.8060800255, -0.282090636501),#rgb(0,0,0) i.e. black
(3.44368272156, -1.11656787037),#rgb(255, 0,0) red
(None, None), #rgb(0,255, 0) green
(3.44368272156, -1.11656787037),#from here all points are colored with the default black color because
#you did not provide sufficient color codes (12) in the list assigned
#to`data[2].marker.color`.
(2.8060800255, -0.282090636501),
(None, None),
(1.91853539044, 0.283726548186),
(2.8060800255, -0.282090636501),
(None, None),
(2.8060800255, -0.282090636501),
(1.91853539044, 0.283726548186),
(None, None)]
That’s why all three points were ploted as black points.
As I also said in the initial comment, the length of color code list should be equal to that of list of x and y- coordinates (counting the None
, too). The list text, of strings to be displayed on hover, also should have the same length.
One more tip: the marker.line.color
cannot be a list of color codes. See details here https://plot.ly/python/reference/#scatter-marker-line-color.