Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using sankey subplots breaks plots depending on trace order. #1527

Closed
SaschaJust opened this issue Apr 18, 2019 · 4 comments
Closed

Using sankey subplots breaks plots depending on trace order. #1527

SaschaJust opened this issue Apr 18, 2019 · 4 comments
Labels
bug plotly.js Issues that would require plotly.js changes

Comments

@SaschaJust
Copy link

Hi,

today I ran into an issue using sankey diagrams in combination with other plots.
This worked just fine in the past, but when I reran notebooks today all plots containing sankeys were broken.

Observed Behavior

I dug a little deeper and found out that the order of the traces affects the success of the plot.
Having sankey as first entry in the Figure.data list works just fine—otherwise the plot breaks. The sankey is not rendered at all and the coordinates of the other plots are off.

Reproduction

import plotly.offline as py
import plotly.graph_objs as go
from plotly import __version__
py.init_notebook_mode(connected=True)
print(__version__)

sankey = go.Sankey(
    domain = go.sankey.Domain(
        x = [0, .45]
    ),
    node=go.sankey.Node(
        label = ['A', 'B', 'C', 'D']
    ),
    link=go.sankey.Link(
        source = [0, 0, 1, 1],
        target = [2, 3, 2, 3],
        value =  [1, 1, 1, 1]
    ),
)

scatter = go.Scatter(
    xaxis='x2'
)

layout = go.Layout(
    xaxis2 = go.layout.XAxis(
        domain = [.55, 1]
    ),
    annotations = [go.layout.Annotation(
        xref='x2',
        x = 1,
        y = 1,
        text = '(1,1)'
    )]
)

Then plotting it like this will work:

fig = go.Figure(data = [sankey, scatter], layout = layout)
py.iplot(fig)

sankey_subplot_working

Using a different order will fail to render the sankey and throw of the coordinates of the scatter plot.

fig = go.Figure(data = [scatter, sankey], layout = layout)
py.iplot(fig)

sankey_subplot_broken

I'm assuming this is a bug, as this has worked before just fine.

I'm not sure whether this is an issue with plotly.py or plotly.js. Apologies in advance, in case this is the wrong tracker.

@jonmmease
Copy link
Contributor

Thanks a lot for the report, and especially for the helpful example. I've opened plotly/plotly.js#3798 to track this in the JavaScript library.

@jonmmease jonmmease added bug plotly.js Issues that would require plotly.js changes labels Apr 22, 2019
@jonmmease
Copy link
Contributor

Closed by plotly/plotly.js#3802 and will be released in plotly.py 3.9.0

@jonmmease
Copy link
Contributor

Hi @SaschaJust, could you try out the 3.9.0 release candidate and check whether this takes care of the issue for you? installation instructions at https://github.com/plotly/plotly.py/blob/release_3.9.0/README.md#installation.

Thanks!

@SaschaJust
Copy link
Author

@jonmmease, this now works perfectly fine in plotly.js and plotly.py (tested with 3.9.0rc1).

Side note: upgrading to 3.9.0 is not required as there were no changes required in the python library and plotly.py loads plotly.latest.min.js, anyways.

Thanks for the great support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug plotly.js Issues that would require plotly.js changes
Projects
None yet
Development

No branches or pull requests

2 participants