'plotly sankey - is it able to put the node labels to the right for last layer(column)
I have a sankey chart created by python plotly with 8 layers(columns).
dataset = pd.read_csv('cleanSankey.csv')
labelListTemp1 = list(set(dataset.source.values))
labelListTemp2 = list(set(dataset.target.values))
labelList = labelListTemp1 + labelListTemp2
sankey_node = list(dict.fromkeys(labelList))
def nodify(node_names):
node_names = sankey_node
# uniqe name endings
ends = sorted(list(set([e[-1] for e in node_names])))
# intervals
steps = 1/len(ends)
# x-values for each unique name ending
# for input as node position
nodes_x = {}
xVal = 0
for e in ends:
nodes_x[str(e)] = xVal
xVal += steps
# x and y values in list form
x_values = [nodes_x[n[-1]] for n in node_names]
y_values = [0.1]*len(x_values)
return x_values, y_values
nodified = nodify(node_names=sankey_node)
fig = go.Figure(data=[go.Sankey( node = dict( pad=15,thickness=15,line = dict(color = "black", width = 0.5),label = labelList,color = 'grey',x=nodified[0],y=nodified[1] ),
link = dict(source = dataset.source.apply(lambda x: labelList.index(x)),
target = dataset.target.apply(lambda x: labelList.index(x)),
value = dataset.value),
arrangement='snap')])
fig.update_layout(title="performance Goal user behavior monitor",margin=dict(l=150))
fig.write_html('perfUXRGoal.html', auto_open=True)
Issue: The labels are positioned to the right side of the nodes, but the the node labels for last layer, it's always positioned to the left side of the nodes.
Question: Is it possible to put the labels to the right side of nodes for the last layer as well?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

