PlotSet LogoPlotSet

How to Create a Sankey Diagram

A step by step walkthrough for turning a source, target and value spreadsheet into a published Sankey diagram in PlotSet, from shaping the sheet to exporting or embedding the finished flow.

Unos 9 minutos

This guide shows how to create a Sankey diagram in PlotSet starting from a plain three column spreadsheet, source, target and value, with nodes named automatically from whatever text sits in those columns and link widths sized to match. We use a budget flow as the running example, but the same three columns work just as well for a website funnel, an energy balance or a customer journey.

Set aside nine minutes if your rows are already in source, target, value shape. That climbs by five if you're reconciling a spreadsheet with a totals row mixed into the real flows, or working out how to fold a dozen small categories into one node before upload.

Los datos que necesitas

Three columns, one row per flow: where the amount comes from, where it goes, and how much. Nodes are created automatically from whatever names appear in the source and target columns, so there is no separate list of nodes to maintain.

CSV de ejemplo
SourceTargetAmount
RevenueCost of Goods420000
RevenueOperating Costs260000
RevenueNet Profit180000
Cost of GoodsManufacturing300000
Cost of GoodsShipping120000
Operating CostsSalaries190000
Operating CostsMarketing70000
Notas

Every amount is a positive number. A Sankey link has no concept of a negative flow, so a refund or a loss needs its own row and its own honestly named target, such as "Returns", rather than a minus sign.

A name that appears in both a source and a target column becomes one node with flow passing through it, which is exactly how a multi-stage diagram like the budget example above works.

Keep source and target names spelled identically everywhere they appear. "Marketing" and "marketing " with a trailing space will render as two separate nodes rather than merging into one.

If a node's inflows and outflows do not add up, PlotSet still draws it, just with a visibly lopsided shape. Reconcile the numbers in your spreadsheet before uploading rather than after.

Los pasos

El camino exacto en PlotSet, desde una plantilla en blanco hasta el gráfico terminado.

  1. 01

    Open the Sankey diagram template

    From the PlotSet dashboard, start a new project and choose the Sankey template. It loads with sample data already bound, so you can see the exact three column shape (source, target, value) before you touch your own file.

    El selector de plantillas de PlotSet: las categorías de gráficos en la columna izquierda, la cuadrícula Bar Charts abierta y la tarjeta de la plantilla Bar Chart con su botón Select visible.
    Todas las guías empiezan aquí. Elige la categoría y luego la plantilla. Es la misma cuadrícula sea cual sea el tipo de gráfico que busques.
  2. 02

    Shape your sheet into source, target and value

    Rework your spreadsheet into one row per flow, in that column order. A pivot table or a report with running totals will not work as is: pull out the individual transitions first, one row per movement from one stage to the next.

  3. 03

    Upload the file or connect a live sheet

    Import a CSV or .xlsx file from the data panel, paste rows directly from a spreadsheet, or connect a Google Sheet if you want the diagram to refresh later without a re-upload. PlotSet reads the first row as your headers.

    La vista de datos del editor de PlotSet: una hoja de cálculo con las columnas Name, Value y Region llenas de cifras de provincias canadienses, junto al panel Data, que ofrece subida de CSV, Magic Import y sincronización con Google Sheet.
    La vista de datos, aquí en un proyecto de gráfico de barras. Sube un CSV, saca los números de una imagen con Magic Import o sincroniza una Google Sheet. El panel es el mismo en todos los tipos de gráfico.
  4. 04

    Map the source, target and value columns

    Confirm which column feeds each role. This is usually automatic when your headers read clearly as Source, Target and Value or similar, but check it by hand if your sheet carries extra columns PlotSet might have guessed on.

    El panel de datos de PlotSet con las asignaciones de columnas resaltadas: Label/time apuntando a la columna A, Values a la columna B y Filter/color a la columna C, con el botón Auto Binding debajo.
    Las asignaciones deciden qué columna se convierte en la etiqueta, cuál aporta los valores y cuál define el color. Auto Binding las deduce de tus encabezados, así que revísalas en lugar de darlas por buenas.
  5. 05

    Order the stages left to right

    PlotSet places nodes by the order flow moves through them, but if your data has a natural sequence (acquisition before conversion before retention, for instance), check the node order matches that story rather than an alphabetical default.

  6. 06

    Label the nodes and turn on link values

    Rename any node whose spreadsheet name would confuse a reader, such as an internal code, to something they would recognize. Turn on the value label so hovering, or the static label itself, shows the exact number each link carries.

  7. 07

    Set node and link colour

    Colour links by their source node by default, which is what lets a reader's eye follow one path through the crossings. Reserve a distinct colour for a terminal node you want to call out, such as a loss or a drop-off, rather than colouring every node differently.

    El editor de PlotSet en la pestaña Preview: un gráfico de tipo Sankey Diagram ya terminado en el lienzo y, a la derecha, el panel de ajustes rodeado por un recuadro rojo.
    La pestaña Preview de un gráfico de tipo Sankey Diagram. Todos los controles de estilo están en el panel enmarcado: apariencia, encabezado, pie de página y las opciones propias de este tipo de gráfico, cada grupo en su propia pestaña.
  8. 08

    Publish, embed or export the diagram

    Publish for a live, interactive diagram where hovering a link shows its exact value and a shareable link, grab the embed code for a page, or export a PNG, SVG or PDF for a deck or report.

Empieza con la plantilla de Sankey Diagram, que ya trae datos de ejemplo cargados, y sustitúyelos por los tuyos.

Abrir la plantilla

Publícalo, incrústalo o expórtalo

El último tramo es igual en todos los tipos de gráfico: Share convierte el gráfico en un enlace público en vivo y un código de incrustación, y Export lo guarda como un archivo estático.

Share: enlace público y código de incrustación

Al activar el código de incrustación y el enlace público, el gráfico queda publicado. El enlace se lo puedes enviar a cualquiera sin problema, y el código de incrustación se coloca en cualquier página como un iframe que conserva los tooltips al pasar el cursor y toda la interactividad. Si editas el gráfico más adelante, haz clic en Recreate para llevar esos cambios a ambos.

La barra de herramientas del editor de PlotSet con el botón Share resaltado, justo al lado del botón Export.
Share es lo que convierte un gráfico terminado en un enlace público y un código de incrustación.
El diálogo Share de PlotSet: el interruptor que activa el código de incrustación y el enlace público, los botones Link, Embed, Facebook, Reddit, Twitter, LinkedIn y Email, y el enlace público del gráfico con un botón Copy.
Activa el código de incrustación y el enlace público, y después copia el enlace o llévate el iframe. Recreate envía las ediciones posteriores a todos los que ya lo tengan.

Export: SVG, PNG o JPG

Export guarda una copia estática en el tamaño que necesites. El SVG se mantiene nítido a cualquier escala y se puede seguir editando en una herramienta de diseño; PNG y JPG son la opción segura para diapositivas y documentos. El multiplicador de escala es lo que te da una imagen nítida en una pantalla retina.

La barra de herramientas del editor de PlotSet con el botón Export resaltado.
Export es el camino hacia un archivo estático para una diapositiva o un informe.
El diálogo Export chart de PlotSet: un selector de escala en 2x, los campos de ancho y alto fijados en 1000 por 600, y el menú de formato abierto con SVG, PNG y JPG.
El SVG se mantiene nítido a cualquier tamaño y se puede seguir editando en una herramienta de diseño; PNG y JPG son la apuesta segura para una presentación. Ajusta la escala antes de exportar para que la imagen se vea nítida en una pantalla retina.

Consejos de estilo para un Sankey Diagram

Aggregate the long tail before you upload

If fifteen small categories each carry under two percent of the total, group them into one "Other" node in your spreadsheet before uploading. Ten legible links reading well beats forty threads nobody can trace, and the reader can still see what the group contains from its label.

Name terminal nodes for what actually happened

A node where flow simply stops should say so plainly: "Churned", "Unconverted", "Written off". A vague label like "Other" at the end of a diagram hides the one part most readers came to see.

Keep the stage count at two or three

Two stages show a split, three show a journey. A fourth stage is where crossings start to dominate the picture, so if your data has more steps than that, consider whether two linked diagrams tell the story more clearly than one dense one.

Let link width do the talking, skip a legend

Because width already encodes the amount, a separate legend explaining colour usually repeats information the diagram already shows. Put your effort into a title that states what is flowing and over what period instead.

Errores comunes al hacer un Sankey Diagram

A node looks wider on one side than the other

This means the inflows and outflows for that node do not sum to the same total. Add up both sides in your spreadsheet: if quantity genuinely disappears at that step, add an explicit row sending the difference to a named node like "Loss" instead of leaving it unbalanced.

The same category shows up as two separate nodes

Check for a spelling or capitalization mismatch between the source and target columns, most often a trailing space or an inconsistent abbreviation. A TRIM and a consistent name in your spreadsheet before re-uploading fixes this in one pass.

The diagram is a tangle of thin crossing links

This happens past roughly a dozen nodes on one stage. Go back to the spreadsheet and merge the smallest categories into a single named group, then re-upload. It is much easier to fix in the source data than to untangle visually after the fact.

Aprende más sobre el Sankey Diagram

¿No estás seguro de que el Sankey Diagram sea la opción correcta? Descubre qué es, cuándo usarlo y cuándo no.

Sobre el Sankey Diagram

Sankey Diagram: preguntas frecuentes

Three columns: source, target and value, one row per flow. Nodes are created automatically from whatever names appear in the source and target columns, so there is no separate node list to build or maintain before uploading.

Crea tu Sankey Diagram ahora

Gratis para empezar con más de 300 plantillas. No se necesita tarjeta de crédito.