
Sankey Diagram in Python
- Basic Sankey Diagram ¶. Sankey diagrams visualize the contributions to a flow by defining source to represent the source node, target for the target node, value to set the flow ...
- Sankey Diagram in Dash ¶. ...
- Style Sankey Diagram ¶. ...
- Hovertemplate and customdata of Sankey diagrams ¶. ...
- Define Node Position ¶. ...
How to create a dynamic flowing Sankey diagram?
What are Sankey diagrams?
- Create a Tidy data frame The very first step in creating visualizations is to get the data in a useful format. ...
- Install the flipPlot package The Sankey diagrams I am using in this post, come from our flipPlots package ( Displayr/flipPlots ). ...
- Create the Sankey diagram
How to create a Sankey diagram in Excel spreadsheet?
- How to Make a Sankey Diagram Excel Dashboard? Step 1: Get Your Data Ready for the Sankey Chart Step 2: Plot Individual Sankey Lines Step 3: Assemble All the Individual ...
- FAQs How do Sankey diagrams work? Why is it called a Sankey Diagram?
- Closing Thoughts
How to build Sankey diagrams in Excel?
- How can I use VLOOKUP to return all the matching items, not just the first?
- How can I sort my information using a formula, so I don’t have to keep clicking the sort button?
- How can I quickly create unique lists of items to use with my SUMIFS calculation?
- How can I stop copying down formulas every time my source data changes.
How to create Sankey diagrams from DataFrames in Python?
Wrapper Function for Plotly’s Sankey
- Take in a dataframe specified by the user
- Creates ‘source’ and ‘target’ pairs according to the column specified by the user
- Creates an aggregated ‘value’ for each ‘source’ and ‘target’ pair
- Feed those values into the fig object as defined by Plotly
- Return a fig object that can be used to create a Plotly Sankey Diagram

What do Sankey diagrams represent?
Sankey diagrams summarise all the energy transfers taking place in a process. The thicker the line or arrow, the greater the amount of energy involved. This Sankey diagram for an electric lamp shows that most of the electrical energy is transferred as heat rather than light.
What is a Sankey energy diagram?
A Sankey diagram is a graphic illustration of flows - like energy, material or money - where they can be combined, split and traced through a series of events or stages (see figure 1). The width of each stream represents the amount of material or energy in the flow.
Why were Sankey diagrams created?
Sankey Diagrams allow reducing complex systems into relatively simple diagrams where the main flows with their corresponding interactions can be seen. They help to locate the dominant contributions in the total flow.
How did the Sankey diagram display its data?
A Sankey Diagram is a visualisation technique that allows to display flows. Several entities ( nodes ) are represented by rectangles or text. Their links are represented with arrow or arcs that have a width proportional to the importance of the flow.
Where are Sankey diagrams used?
Sankey diagrams visualize material, energy and cost flows shown proportionally to the flow quantity. They are often used in energy management, manufacturing or in fields of science.
Why is Sankey diagram is useful in energy balance calculation?
Sankey diagrams summarise all the energy transfers taking place in a process. The thicker the line or arrow, the greater the amount of energy involved. Sankey diagrams are widely used in technology where material and energy balances have to be visualized.
What is the meaning of Sankey?
Irish: shortened Anglicized form of Gaelic Mac Seanchaidhe 'son of the chronicler' a name found in Sligo and Leitrim. However it is more commonly Anglicized as Fox as the result of an erroneous association with sionnach 'fox'.
What is the importance of energy flow diagram?
Energy flow diagrams are also a great tool to trace energy losses within a production line or a technical process. They help identifying at which stage losses occur. In this sample energy flows are shown for the generation of natural gas out of biomass (wood). The chart shows precisely how the process heat is re-used.
How do you draw a Sankey diagram?
1:034:24The 5 steps to drawing a perfect Sankey diagram - YouTubeYouTubeStart of suggested clipEnd of suggested clipNow step one of drawing a Sankey diagram is you got to decide on what your scales are gonna. Be. SoMoreNow step one of drawing a Sankey diagram is you got to decide on what your scales are gonna. Be. So I've got 800 joules of electrical. Energy is my input energy here.
How do you analyze a Sankey diagram?
The key to reading and interpreting Sankey Diagrams is remembering that the width is proportional to the quantity represented. In the example below, the audience quickly sees that largest destination for water is terrestrial evaporation, among other features of the hydrologic cycle.
Why is it called Sankey?
The name Sankey is thus probably of Norse origin, and the most likely etymology is from "sand-ey", a sand island. Sand bars and islands are a conspicuous feature of the north side of the Mersey, particularly at the entrance to Sankey Brook.
How do you draw a Sankey diagram?
1:034:24The 5 steps to drawing a perfect Sankey diagram - YouTubeYouTubeStart of suggested clipEnd of suggested clipNow step one of drawing a Sankey diagram is you got to decide on what your scales are gonna. Be. SoMoreNow step one of drawing a Sankey diagram is you got to decide on what your scales are gonna. Be. So I've got 800 joules of electrical. Energy is my input energy here.
What is an energy flow diagram?
Energy flow diagrams can illustrate how energy is transformed from one form of energy to other forms of energy. There is often branching where one form of energy can be transformed into two or more other forms at the same time. The diagram shows a mobile phone in use.
How do you make a Sankey diagram?
1:0319:18How to Make a SANKEY diagram for Free (Step-by-Step) - YouTubeYouTubeStart of suggested clipEnd of suggested clipThat you need to to give. Now you might of course understand that if you want a complex sankeyMoreThat you need to to give. Now you might of course understand that if you want a complex sankey diagram or a more you know elaborate tank diagram you might have more than one of these flows.
What is an energy transfer diagram?
An energy transfer diagram or a Sankey diagram is used to show the transfer of energy across a process or a device. It is a flow diagram in which the widths of the arrows show the relative amounts of each type of energy.
What is a Sankey diagram?
Sankey diagrams are a type of flow diagram in which the width of the arrows is proportional to the flow rate. The illustration shows a Sankey diagram that represents all the primary energy that flows into a factory. The widths of the bands are linearly proportional to energy production, utilization and loss. The primary energy inputs enter the left ...
What is the primary input of a Sankey diagram?
The primary energy inputs enter the left side of the diagram, and are differentiated into gas, electricity and coal/oil. Sankey diagrams can also visualize the energy accounts, material flow accounts on a regional or national level, and cost breakdowns.
What is the purpose of the Sankey model?
Over time, it became a standard model used in science and engineering to represent heat balance, energy flows, material flows , and since the 1990s this visual model has been used in life-cycle assessment of products. Minard's classic diagram of Napoleon 's invasion of Russia, using the feature now named after Sankey.
How to create a Sakey diagram with Highcharts?
As mentioned, it is simple to create a Sankey diagram with Highcharts; you begin with writing down the nodes structure using three parameters under data. For example, if node A provides to node B a flow of data with a quantity of 10 units, our data structure will be ["node A", "node B", 10], that is it, it is that straightforward.
Don't miss a byte
Never miss important news, tips, and tricks that will help you get the most out of your Highcharts products. We won’t spam you, sell your contact info or do anything else that would betray your trust.
Data visualization: Sankey Diagram
The Sankey diagram is a type of data visualization that allows you to graphically represent the flow from one series of values to another.We tell you how and when you can use it and show you how other people are using it.
What does a Sankey diagram do?
This diagram shows the data flow between categories and their volume in a proportionate way. This volume is the magnitude of the relationship between these categories and is represented by arrows. The wider they are, the greater the strength of the relationship.
A bit of history
The Sankey diagram is named after its creator, Irish Captain Matthew Sankey, who used it in 1898 to show the energy efficiency of a steam engine. In his initial design, Sankey depicted the steam flow with different shades for each type of flow affecting the main.
Other uses of the Sankey diagram
Today, the Sankey diagram is used to visualize the product lifecycle assessment plans and to visualize cash flows. One of its most popular uses is implemented by Google Analytics in its reports to show how users move through the web:
Sankey and flowcharts
As such, the Sankey diagram is a specific type of flowchart. This diagram is used to analyze, plan and demonstrate processes in a simple way. Each of the steps in the process is represented by different geometric figures that signify a specific type of step. It is also symbolized by arrows that indicate the order and flow of the categories.
How can you create a Sankey diagram?
At Datasketch, our Sankey diagram apps will help you visualize the flow of your data simply and attractively. On our website, you will find an app for a simple Sankey diagram and another app for an interactive Sankey diagram.
What is a Sankey diagram?
Sankey Diagrams allow reducing complex systems into relatively simple diagrams where the main flows with their corresponding interactions can be seen. They help to locate the dominant contributions in the total flow.
What is the orientation of a Sankey diagram?
The diagrams can have a horizontal or vertical orientation, but they are generally represented from left to right, or from top to bottom. They usually have different colors to indicate different materials or different dimensions. Fig.2: schematic representation of a Sankey Diagram: nodes in blue, links in other colors.
Why are flow charts used?
WHY: Flowcharts are widely used in many technical and non-technical fields to study, improve, and communicate complex processes through simple and clear diagrams. Sankey Diagrams are a specific type of flow diagrams characterized by the presence of nodes linked by directed arrows representing flows of the process under study.
How to generate a diagram?
To generate the diagram you have to supply numerical values to the arguments flows, labels, orientations, and pathlengths. The values of the argument flows indicate the sizes of the flows, with positive values for the inputs and negative values for the outputs.
When was the diagram of steam engines invented?
The quote refers to a diagram invented by the captain in 1898 to visualize the energy flows in the steam engines that he studied in absolute detail. Figure 1 reproduces the original diagram of 1898.
Is a Sankey diagram an alluvial diagram?
Not all the visualization tools have the alternative of feedback or recycling in their Sankey functions. Sankey Diagrams should not be confused with Alluvial Diagrams. As indicated by Wikipedia: “Alluvial diagrams are a type of flow diagram originally developed to represent changes in network structure over time.
Definition
A Sankey diagram is a visual representation in the form of flow. This flow gets distributed according to the dataset and flows towards other nodes. Links are the points where flow meets nodes. These diagrams highlight the width of flows with their distribution visually.
Why do you need it?
We need a Sankey diagram to show many-to-many relationships. This diagram is really useful for leaders to stand out from the data. We should keep in mind not to use complex data by this diagram, as it may conceal the desired output instead of highlighting.
What kind of data you can visualize with it?
A Sankey diagram is best suited to data that indicates flow. If you have data on the flow of energy in a system, then this diagram could be the one for you. The place where the width of flow is more indicates that it consumes high energy and can be improved instantly. Other examples of such datasets are material flow, the flow of money, etc.
What is a Sankey diagram?
Sankey diagrams are a specific type of flow diagram typically used to visualise the flow of material, energy, cost, or any measurable resource, shown proportionally to the flow quantity.
Why is a Sankey diagram hard to digest?
If your audience is new to data visualization, Sankey diagrams are hard to digest for them. Sankey diagrams can make it difficult to differentiate when flows have similar widths. If the nodes are not spaced out well, the Sankey diagram cannot highlight an actionable insight, because of the link overlapping and could result in cluttering.
How many nodes are there in a Sankey diagram?
A Sankey diagram has multiple nodes which are connected by a link. Each node should only appear once and there can be utmost one link between a pair of nodes. They are widely used in energy efficiency, marketing analysis, supply chain management, production systems and many other industries.
Is a Sankey diagram a good visualization tool?
Sankey diagram is a very effective data visualization tool. Of course, while the Sankey Diagram can simplify the visualization of the data, the user's understanding and experience with DV who is consuming this information also matters, because of the complexity of the chart itself.

Overview
Sankey diagrams are a type of flow diagram in which the width of the arrows is proportional to the flow rate.
Sankey diagrams can also visualize the energy accounts, material flow accounts on a regional or national level, and cost breakdowns. The diagrams are often used in the visualization of material flow analysis.
History
Sankey diagrams are named after Irish Captain Matthew Henry Phineas Riall Sankey, who used this type of diagram in 1898 in a classic figure (see diagram) showing the energy efficiency of a steam engine. The original charts in black and white displayed just one type of flow (e.g. steam); using colors for different types of flows lets the diagram express additional variables.
Science
Sankey diagrams are often used in fields of science, especially physics. They are used to represent energy inputs, useful output, and wasted output.
Active examples
The United States Energy Information Administration (EIA) produces numerous Sankey diagrams annually in its Annual Energy Review which illustrate the production and consumption of various forms of energy.
The US Department of Energy's Lawrence Livermore Laboratory maintains a site of Sankey diagrams, including US energy flow and carbon flow.
See also
• Alluvial diagram – a type of Sankey diagram that uses the same kind of representation to depict how items re-group
• Material flow management
• Thermodynamics
• Time geography
External links
• RAWGraphs online open-source platform allowing the creation of Sankey diagrams
• Scottish Executive – Energy in Scotland: Supply and Demand
• Irish Environmental Protection Agency – Material Flow Accounts (MFAs) – Demonstration for Ireland – 2001