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

plotly.graph_objects.Sankey docs incorrectly indicates support for legends #2517

Open
ned9 opened this issue May 29, 2020 · 7 comments
Open

Comments

@ned9
Copy link

ned9 commented May 29, 2020

I'm trying to display a legend with a Sankey diagram. I gather this is intended to be possible as the docs state this for the name param for plotly.graph_objects.Sankey: Sets the trace name. The trace name appear as the legend item and on hover.

I can't see the legend appearing however, nor the trace name appearing on hover. The following example demonstrates the issue for me:

import plotly.graph_objects as go

go.Figure({
    'data': [
        {'link': {'source': [0, 0, 0, 1, 1, 1, 2, 2],
                  'target': [3, 4, 5, 3, 4, 5, 3, 5],
                  'value': [10, 20, 20, 10, 5, 5, 20, 10]},
              'name': 'Trace 1',
              'node': {'label': ["A", "B", "C", "D", "E", "F"]},
              'type': 'sankey'
             },
    ],
    'layout': {'showlegend': True}
})

I'm using Plotly 4.8.1.

I also came across this Stack Overflow question that makes me wonder if this person is experiencing the same issue as me.

@nicolaskruchten
Copy link
Member

Unfortunately I think the legend doc entry is a little misleading in this case. It refers to what this attribute does for traces in general, when they support legends, but actually Sankey traces don't support legends at all. Sorry about the confusing docs, I'll see what we can do to fix them.

@ineelshah
Copy link

Unfortunately I think the legend doc entry is a little misleading in this case. It refers to what this attribute does for traces in general, when they support legends, but actually Sankey traces don't support legends at all. Sorry about the confusing docs, I'll see what we can do to fix them.

I can help to fix it. It looks like an easy issue to fix unless you think it is more complex than changing the explanation provided in the docs for "name", This can be a good first issue for me to solve.
Just brief me about how to solve this.
Can I work on it?

@ned9
Copy link
Author

ned9 commented May 30, 2020

Ah right, well that explains things. Thanks for clearing that up. So the name param does nothing for Sankey plots then?

@ned9 ned9 changed the title Legend not displaying in Sankey Diagram plotly.graph_objects.Sankey docs incorrectly indicates support for legends May 30, 2020
@nicolaskruchten
Copy link
Member

It doesn’t really do much, no. It’s a parameter that’s available for all traces for consistency but absent a legend it’s only visible in hoverlabels, and in the case of Sankey traces, by default it’s not even shown there.

@nicolaskruchten
Copy link
Member

@ineelshah thanks for the enthusiasm! This particular issue is a bit tricky to resolve, as the Python code and documentation in question is auto-generated from the Javascript code in https://github.com/plotly/plotly.js

@fstricker
Copy link

Is this issue still unresolved? There are ways to bypass the problem when building a Dash app, but for standalone Plotly Sankey charts, this looks like a brutal show stopper.

@maciejskorski
Copy link

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants