plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Sankey Plot Node Positions are incorrect

Open akhildevelops opened this issue 6 years ago • 0 comments

Describe your context

  • replace the result of pip list | grep dash below
dash                 1.5.1              
dash-core-components 1.4.0              
dash-html-components 1.0.1              
dash-renderer        1.2.0              
dash-table           4.5.0  

Describe the bug

Want to position Nodes along X-Axis in a Sankey Plot and Y to be automatically Adjusted. When I define X Positions only Sankey doesn't align the Nodes. But If I define Y Positions then only Sankey aligns the Nodes.

    def create_sankey_plot(self, source_r, target_r, value_r, colors_r,
                           labels_r, labels_a, colors_a):
        return go.Sankey(
            node=dict(
                pad=15,
                thickness=20,
                line=dict(color="black", width=0.5),
                label=labels_a,
                color=colors_a,
                x=[0.2, 0.1, 0.5, 0.7, 0.3, 0.5]
            ),
            link=dict(
                source=source_r,
                target=target_r,
                value=value_r,
                color=colors_r,
                line={'width': 1},
                label=labels_r
            )
        )

Above code will not align Nodes. Below code works:

def create_sankey_plot(self, source_r, target_r, value_r, colors_r,
                           labels_r, labels_a, colors_a):
        return go.Sankey(
            node=dict(
                pad=15,
                thickness=20,
                line=dict(color="black", width=0.5),
                label=labels_a,
                color=colors_a,
                x=[0.2, 0.1, 0.5, 0.7, 0.3, 0.5],
                y=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
            ),
            link=dict(
                source=source_r,
                target=target_r,
                value=value_r,
                color=colors_r,
                line={'width': 1},
                label=labels_r
            )
        )

Expected behavior

Align Nodes if provided only X values / Y values making other default.

akhildevelops avatar Jan 03 '20 09:01 akhildevelops