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?
Asked
Active
Viewed 838 times
2 Answers
8
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!
-
-
@GaetaanA I can write
(1.5,.5) -- (1.5,-1.5), they are the same. Basically++helps you to "shift" coordinates. – May 23 '19 at 14:56
7
Even though I only have claws my handclaw writing is more readable than yours, I think.
\documentclass[tikz,border=3.14mm]{standalone}
\newcounter{ahead}
\begin{document}
\begin{tikzpicture}[ahead/.style={/utils/exec=\stepcounter{ahead},
insert path={ -- ++ (0,#1/2) -- ++(#1,-#1) coordinate(ahead-\number\value{ahead}) --
++ (-#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]
(aux)[ahead=0.6,rounded corners=4pt] |-++(-2.5,0) [sharp corners]
|- ++(2,-1.5) [ahead=0.8,rounded corners=4pt]
|-++(-2,0) [sharp corners] |- ++(2,-1.5) [ahead=0.8,rounded corners=8pt] -| (start);
\path (ahead-1) node[right] {Tank in total\\ 21\%}
(ahead-2) node[below right] {unreadable\\ xx\%}
(ahead-3) node[below] {unreadable\\ xx\%}
(ahead-4) node[below] {unreadable\\ xx\%};
\end{tikzpicture}
\end{document}
-
3As far as I know, the width of the arrows must (or should) be proportional to its value, i.e. 14% arrow must be thinner than 35% arrow. – May 23 '19 at 14:17
-
@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. – May 23 '19 at 14:22 -
Thanks a lot! Yes my writing is unreadable haha, anyway thanks. i'll try to adjust the width and color myself now :) what is says is 'exhaust loss, cooling loss, mechanical & radiation loss' – Gaetaan A May 23 '19 at 14:51


just-do-it-for-mequestion. – Raaja_is_at_topanswers.xyz May 24 '19 at 06:34