question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sankey node x and y positions require both variables set to reflect in chart.

See original GitHub issue

This is somewhat of a duplicate of #960 and #1437 but slightly more hopeful 😃 The x and y arguments of the nodes dict do successfully control node location, however – it appears that both arguments must be supplied.

import dash
import dash_core_components as dcc
import dash_html_components as html
f#rom dash.dependencies import Output, Input, State
import plotly.graph_objs as go
#import pandas as pd

app = dash.Dash()
app.layout = html.Div([
    dcc.Graph(
        id = 'wut',
        figure={
            'data' : [
                dict(
                    type='sankey',
                    #domain = 
                    arrangement = 'fixed',
                        node = dict(
                            pad = 15,
                            thickness = 20,
                            line = dict(color = "black", width = 0.5),
                            label = ["A1", "A2", "B1", "B2", "C1", "C2"],
                            x = [0.1, 0.2, 0.24, 0.7, 0.8, .9],
                            y = [0, .2, .3, .4, .5, .6],
                            color = "blue"
                    ),
            link = dict(
                source = [0, 1, 0, 2, 3, 3], # indices correspond to labels, eg A1, A2, A2, B1, ...
                target = [2, 3, 3, 4, 4, 5],
                value = [8, 4, 2, 8, 4, 2]
            ))        
        ]}   
)])

if __name__ == '__main__':
    app.run_server(debug=True)

VS.

import dash
import dash_core_components as dcc
import dash_html_components as html
f#rom dash.dependencies import Output, Input, State
import plotly.graph_objs as go
#import pandas as pd

app = dash.Dash()
app.layout = html.Div([
    dcc.Graph(
        id = 'wut',
        figure={
            'data' : [
                dict(
                    type='sankey',
                    #domain = 
                    arrangement = 'fixed',
                        node = dict(
                            pad = 15,
                            thickness = 20,
                            line = dict(color = "black", width = 0.5),
                            label = ["A1", "A2", "B1", "B2", "C1", "C2"],
                            ###x = [0.1, 0.2, 0.24, 0.7, 0.8, .9],
                            y = [0, .2, .3, .4, .5, .6],
                            color = "blue"
                    ),
            link = dict(
                source = [0, 1, 0, 2, 3, 3], # indices correspond to labels, eg A1, A2, A2, B1, ...
                target = [2, 3, 3, 4, 4, 5],
                value = [8, 4, 2, 8, 4, 2]
            ))        
        ]}   
)])

if __name__ == '__main__':
    app.run_server(debug=True)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

14reactions
johentschcommented, Jan 29, 2020

+1 for the possibility to define x coordinates only.

0reactions
johentschcommented, Aug 3, 2022

That would indeed be a helpful workaround, haven’t found a way to retrieve coordinates so far, anyone else?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plotly Sankey Diagram: how to set position of nodes, explicit X ...
Hope someone has a suggestion! When I dont specify X and Y positions, the Sankey plot looks okay in terms ...
Read more >
Chapter 9 Other Graphs - Data Visualization with R
In a Sankey diagram, the width of the line between two nodes is proportional to the flow amount. We'll demonstrate this with UK...
Read more >
Sankey Diagram | Charts - Google Developers
A sankey diagram is a visualization used to depict a flow from one set of values to another. The things being connected are...
Read more >
Sankey chart cut-off with vertical orientation and set x/y node ...
Unfortunately, I am having problems with generating a good responsive sankey figure. Specifically, when using defined x and y node positions ...
Read more >
Creating Custom Sankey Diagrams Using R - Displayr
A Sankey diagram consists of three sets of elements: the nodes, ... example above: the position of the nodes reflects places in France,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found