# How to draw Sankey diagram with Tikz? [duplicate]

I'm trying to make a Sankey diagram. I know it's possible with Tikz picture but I don't get the hang of it. I'm trying to make something like this: Is there anyone who has experience with this package?

## marked as duplicate by Raaja, Stefan Pinnow, Dr. Manuel Kuehner, siracusa, MenschMay 24 at 7:06

• We know that you are not able to draw this completely, but could you please provide all what you have tried? – user156344 May 23 at 13:46
• First I started looking at some other questions e.g : tex.stackexchange.com/questions/40159/…. But I have no clue on how to start with this. Is there a pdf that explains it step by step? – Gaetaan A May 23 at 13:49
• What we are asking about is an example code. At least you should know we do not want to draw everything from scratch. – user156344 May 23 at 13:49
• Maybe I asked it the wrong way, my english is not that good. I didn't mean to ask drawing it yourself from scratch. What I meant to ask was, is there any pdf that explains this step by step? Because when looking at other examples the code doesn't make sense to me at all. I started using Latex a few weeks ago.. But to answer your question, no I don't have an example code or at least not somethin that I tried – Gaetaan A May 23 at 13:57
• I'm voting to close this question as off-topic because this is a just-do-it-for-me question. – Raaja May 24 at 6:34

It is not easy to understand the accepted answer in your reference question, however, with some simple calculations we can draw it quite directly as follows.

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[{Triangle Cap[reversed]}-,line width=1cm] (0,0) -- (1.5,0);
\draw[-{Triangle[width=.35cm*1.5,length=.35cm]},line width=.35cm] (1.5,.5) -- ++ (0,-2);
\draw[-{Triangle[width=.3cm*1.5,length=.3cm]},line width=.3cm] (2.5,.5) -- ++ (0,-2);
\draw[-{Triangle[width=.14cm*1.5,length=.14cm]},line width=.14cm] (3.5,.5) -- ++ (0,-2);
\draw[-{Triangle[width=.21cm*1.5,length=.21cm]},line width=.21cm] (3.5,.395) -- ++ (2,0);
\draw[line width=.65cm] (1.5,.175) -- (2.5,.175);
\draw[line width=.35cm] (2.5,.325) -- (3.5,.325);
\end{tikzpicture}
\end{document}


Adding the text, changing the color, and rescaling the picture so that it fits your document are what you have to do now. Hope you can do it!

• Thanks a lot! What does this part mean '(1.5,.5) -- ++ (0,-2);' – Gaetaan A May 23 at 14:54
• @GaetaanA I can write (1.5,.5) -- (1.5,-1.5), they are the same. Basically ++ helps you to "shift" coordinates. – user156344 May 23 at 14:56

Even though I only have claws my handclaw writing is more readable than yours, I think.

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
++ (-#1,-#1) -- ++(0,#1/2) }},nodes={align=center}]
\draw (0,0) coordinate(start) -- ++(0.75,0.75) -- ++ (-0.75,0.75)
node[below left]{100\%\\ Diesel}
-- ++(10,0) [ahead=1] -| ++(-3,-3) coordinate(aux)  [rotate=-90]

• @JouleV Thanks! Yes, you can adjust this with the argument of the ahead, which precisely takes one argument that controls its width. More precisely, you can adjust this if you can read the numbers on the screen shot, which I can't. – user121799 May 23 at 14:22