plotly / plotly/plotly.py

plotly.graph_objects.Sankey docs incorrectly indicates support for legends

Open
#2,517 9 comments 4 reactions 1 assignee View on GitHub

@LiamConnors is already working on this.

Since Jul 8, 2024.

documentation P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.