Further Adventures in Plotly Sankey Diagrams

Tom Welsh
18 min readApr 11, 2023

The adventure continues

Styled Plotly Sankey — Image by Author — Data from Economy App

This is a continuation, mayhaps even a leap further, in Plotly Sankey Diagrams. If you are new to the subject, you may wish to read my previous article on Understanding Plotly Sankey Diagrams, which takes you through creating your first Sankey and the process I use to understand their creation.

This article builds on the previous article and will cover the following points.

  • Specifying colours for nodes
  • Specifying colours for links
  • Specifying X and Y coordinates for nodes
  • Adding annotations to the Sankey
  • Hiding label text on the diagram but having it available when hovering your mouse over an area.

The Problem

Having logged in to the excellent Plotly Community Forums, I found a query from a forum user on one of my earlier posts; they asked if I had created Sankeys with similar Level 1 and Level 2 nodes but different Level 3’s etc. To aid in their question, they posted the following image of a Sankey from EconomyApp

Alphabet Quarter 3 FY2022 Income Statement
EconomyApp Sankey of Alphabet Q3 FY 2022 Income Statement

--

--

Tom Welsh

Python aficionado, passionate about data analysis & visualization. Tech-savvy, Cybersecurity & Risk professional by day, Linux & IT infrastructure by night.