1

This is my code:

def fig_sankey_creator(sankey_label, sankey_source, sankey_target, sankey_value, node_color, link_color):   




    fig_sankey = go.Figure(data = [go.Sankey(
                                node = dict(
                                label = sankey_label,
                                color = node_color,
                                pad = 10,
                            ),
                                link = dict(
                                        source = sankey_source,
                                        target = sankey_target,
                                        value = sankey_value,
                                        color = link_color,
                            ))])
    fig_sankey.update_layout(
            title_text = "Sankey diagram",
            height = 800,
            width = 1600,
            )
    fig_sankey.update_yaxes(ticklabelposition = "outside")
            
    return fig_sankey

and this is the outcome: enter image description here

What I want to change is the axis labels not to be inside the plot but outside. How to achieve that? The ticklabelposition outside does not work. Thanks!

Hamzah
  • 8,175
  • 3
  • 19
  • 43
Mr.Slow
  • 490
  • 1
  • 1
  • 16
  • You meant the tick labels of yaxis? – Hamzah Dec 02 '22 at 10:32
  • Yes, the numbers (IDs) next to the nodes. I want them to be outside of the plot. – Mr.Slow Dec 02 '22 at 10:37
  • 1
    Does this answer your question? https://stackoverflow.com/a/71053171/16733101 – Hamzah Dec 02 '22 at 10:40
  • It shows all the tick labels on the same (right side), I would prefer tick labels on the left side for the left nodes and vice versa for the right side. Just trying to avoid the tick labels to stay in the way of the Sankey links. – Mr.Slow Dec 02 '22 at 10:58
  • 1
    You may need to try a different library like [Holoviews](https://holoviews.org/reference/elements/bokeh/Sankey.html). Using `label_position='outer'` would work. Don't believe plotly sankey has this feature – Redox Dec 02 '22 at 16:21

0 Answers0