plotly / plotly/plotly.py

textfont color ignored in Sankey diagram

Open
#2,741 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When specifying textfont in a Sankey diagram like this: textfont=dict(color="blue", size=50) the color is ignored, while size works correctly.

A MWE with two figures. The first one has black nodes and (tiny) text, which is correct.

fig_black = go.Figure(data=[
    go.Sankey(
        node=dict(
            pad=15,
            thickness=20,
            line=dict(color="black", width=0.5),
            label=["A1", "A2", "B1", "B2", "C1", "C2"],
            color="black"
        ),
        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]
        ),
        textfont=dict(color="black", size=10)
    ),
])
fig_black.update_layout(title_text="Black")
fig_black.show()
Screenshot 2020-09-02 at 02 49 36

The second one has blue nodes, which is correct, but the text is black when it should be blue.

fig_blue = go.Figure(data=[
    go.Sankey(
        node=dict(
            pad=15,
            thickness=20,
            line=dict(color="blue", width=0.5),
            label=["A1", "A2", "B1", "B2", "C1", "C2"],
            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]
        ),
        textfont=dict(color="blue", size=50)
    ),
])
fig_blue.update_layout(title_text="Blue")
fig_blue.show()
Screenshot 2020-09-02 at 02 50 42

I'm using plotly version 4.9.0.

Is the color specification above wrong or is this a bug?

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.

Research direction

Reproduce the supplied two-figure Sankey MWE with Plotly 4.9.0 and compare the working text size with the ignored text color. Trace the Sankey textfont handling, then add coverage showing that the requested color is rendered; the issue names no source file or test to begin with.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.