Skip to content

Sankey text font{color} property not changing font color. #2845

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

Closed
Dekermanjian opened this issue Oct 19, 2020 · 8 comments
Closed

Sankey text font{color} property not changing font color. #2845

Dekermanjian opened this issue Oct 19, 2020 · 8 comments

Comments

@Dekermanjian
Copy link

Hello, I am not sure if this is a bug, but the textfont property is not allowing me to change the text color of the Sankey diagram. The size and family arguments work as expected.

import plotly.graph_objects as go

fig = 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 = "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="red", family = "arial", size = 20)
)])

fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
fig.show()
@SriBhuvaneswari
Copy link

I think I can work on this.

@Dekermanjian
Copy link
Author

Hi, were able to reproduce the error? Is this a bug?

@EloiseRosen
Copy link

Having the same problem!

@xeladsn
Copy link

xeladsn commented May 24, 2021

For now, as a an alternative, you can override the text class attributes in HTML/CSS in order to style your text. For example, in my styles.css file, I have added the following :

.node-label-text-path {
  fill: rgb(250, 250, 250) !important;
  text-shadow: none
}

Works well for me !

Btw issue is duplicate of #2741

@Nemecsek
Copy link

The issue is open, but it is working in plotly 5.3.1

@Cheeseycube
Copy link

Just curious, is this still an issue or am I just bad at setting the font? Below is my code which sets the font properly if I use show() but not when I convert it to JSON and add it to my Flask dashboard.
fig = go.Figure()

    fig.add_trace(go.Sankey(valuesuffix=value_suffix,
                node=dict(label=labels, color=label_colors),
                link=dict(
                    source=links["source"],
                    target=links["target"],
                    value=links["value"],
                    color=links["link_c"],
                ),
                textfont={'color': 'pink'}))
    # Customize plot based on earlier values
    fig.update_layout(
        title_text=title,
        font_size=font_size,
        font_family=font_family,
        font_color=font_color,
        #width=1000,
        #height=600,
        paper_bgcolor=bg_color,  # (use color name or hex code)
        title={"y": 0.9, "x": 0.5, "xanchor": "center", "yanchor": "top"}  # Centers title
    )

@gvwilson
Copy link
Contributor

gvwilson commented Jul 8, 2024

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Alternatively, if it's a request for tech support, please post in our community forum. Thank you - @gvwilson

@gvwilson gvwilson closed this as completed Jul 8, 2024
@acies-laaveshwaran-parthiban
Copy link

acies-laaveshwaran-parthiban commented Apr 28, 2025

Hi. Issue is still present. Cannot change the color of the text of the Sankey node labels.

Streamlit version: 1.42.2

Workaround as mentioned above can be to link a css file and use the below css snipet:

.node-label {
    fill: rgb(0, 0, 0) !important;
    text-shadow: none !important;
}

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

8 participants