| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2016-2025 by Paul Gaborit |
| 4 |
% ----------------------------------- |
| 5 |
% |
| 6 |
% This work may be distributed and/or modified under the conditions of |
| 7 |
% the LaTeX Project Public License, either version 1.3 of this license |
| 8 |
% or (at your option) any later version. The latest version of this |
| 9 |
% license is in |
| 10 |
% |
| 11 |
% <http://www.latex-project.org/lppl.txt> |
| 12 |
% |
| 13 |
% and version 1.3 or later is part of all distributions of LaTeX version |
| 14 |
% 2005/12/01 or later. |
| 15 |
% |
| 16 |
% This work has the LPPL maintenance status “maintained”. |
| 17 |
% |
| 18 |
% The Current Maintainer of this work is Paul Gaborit. |
| 19 |
% |
| 20 |
% This work consists of the files sankey.dtx, sankey.ins and the derived |
| 21 |
% files sankey.sty, tikzlibrarydubins.code.tex, sankey-doc-preamble.sty, |
| 22 |
% sankey-example1.tex, sankey-example2.tex, sankey-example3.tex, |
| 23 |
% sankey-example3-variation.tex, sankey-example4.tex, |
| 24 |
% sankey-example-energy.tex |
| 25 |
% |
| 26 |
% |
| 27 |
% \fi |
| 28 |
% |
| 29 |
% \iffalse |
| 30 |
% |
| 31 |
%<*driver> |
| 32 |
\documentclass[a4paper,10pt,draft]{ltxdoc} |
| 33 |
\SetupDoc{reportchangedates} |
| 34 |
\usepackage{sankey-doc-preamble} |
| 35 |
\EnableCrossrefs |
| 36 |
\CodelineIndex |
| 37 |
\RecordChanges |
| 38 |
\begin{document} |
| 39 |
\DocInput{sankey.dtx} |
| 40 |
\end{document} |
| 41 |
%</driver> |
| 42 |
% \fi |
| 43 |
% |
| 44 |
% \GetFileInfo{\jobname.dtx} |
| 45 |
% |
| 46 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 47 |
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ } |
| 48 |
% \DoNotIndex{\begingroup,\endgroup,\begin,\end} |
| 49 |
% \DoNotIndex{\def,\edef,\gdef,\xdef,\ifx,\else,\string,\relax} |
| 50 |
% \DoNotIndex{\csname,\endcsname,\ifcsdef,\expandafter,\ifnumgreater} |
| 51 |
% \DoNotIndex{\NewDocumentCommand,\NewDocumentEnvironment,\IfBooleanTF} |
| 52 |
% \DoNotIndex{\NewCommandCopy,\NewExpandableDocumentCommand} |
| 53 |
% \DoNotIndex{\NeedsTeXFormat,\ProvidesPackage,\RequirePackage,\PackageError,\PackageWarning} |
| 54 |
% \DoNotIndex{\newtoggle,\toggletrue,\togglefalse,\iftoggle,\ifdefempty,\ifundef,\ifdefstrequal} |
| 55 |
% \DoNotIndex{\ifbool,\ifdef,\ifnumequal,\colorlet,\fpeval,\inteval,\newbool} |
| 56 |
% \DoNotIndex{\pgfmathsetmacro,\pgfdeclarelayer,\pgfdeclareshape,\pgfkeys,\pgfset,\usetikzlibrary} |
| 57 |
% \DoNotIndex{\the,\pgf@x,\pgf@y,\tikz@scan@one@point,\pgfutil@firstofone} |
| 58 |
% \DoNotIndex{\pgfsetlayers,\inheritsavedanchors,\inheritanchor,\inheritanchorborder,\anchor,\pgf@process,\northeast,\southwest} |
| 59 |
% \DoNotIndex{\pgfmathresult,\pgfinterruptpath,\endpgfinterruptpath,\pgfkeysvalueof,\pgfmathtruncatemacro,\pgfmathparse} |
| 60 |
% \DoNotIndex{\tikzset,\pgfextra,\pgflinewidth,\foreach,\coordinate} |
| 61 |
% \DoNotIndex{\path,\node,\pgfmathprintnumber,\n,\p,\x,\y} |
| 62 |
% \DoNotIndex{\tiny,\ttfamily,\space} |
| 63 |
% |
| 64 |
% \title{The \textsf{sankey} package\\ |
| 65 |
% Draw Sankey diagrams via TikZ} |
| 66 |
% |
| 67 |
% \author{Paul Gaborit |
| 68 |
% (\href{mailto:[email protected]}{\texttt{[email protected]}})} |
| 69 |
% \date{\fileversion{} -- \filedate{}} |
| 70 |
% |
| 71 |
% \GetFileInfo{sankey.sty} |
| 72 |
% |
| 73 |
% \def\manualparts{ |
| 74 |
% \begin{quote} |
| 75 |
% This manual contains three parts: |
| 76 |
% \nameref{usermanual} (p.\pageref{usermanual}), |
| 77 |
% \nameref{examples} (p.\pageref{examples}) |
| 78 |
% and \nameref{implementation} (p.\pageref{implementation}). |
| 79 |
% \end{quote} |
| 80 |
% } |
| 81 |
% |
| 82 |
% \maketitle |
| 83 |
% |
| 84 |
% \hypersetup{ |
| 85 |
% pdftitle=How to use the sankey package to build Sankey diagrams (\fileversion), |
| 86 |
% pdfauthor=Paul Gaborit, |
| 87 |
% } |
| 88 |
% |
| 89 |
% \def\ttintitle#1{\textmd{\textcolor{red!50!black}{\texttt{#1}}}} |
| 90 |
% |
| 91 |
% |
| 92 |
% \begin{abstract} |
| 93 |
% The \code{sankey} package provides macros and environments to |
| 94 |
% build \emph{Sankey |
| 95 |
% diagrams}\footnote{\url{https://en.wikipedia.org/wiki/Sankey_diagram}}, |
| 96 |
% i.e. \emph{flow diagrams} in which the width of the arrows is |
| 97 |
% proportional to the flow rate. The initial idea for the first |
| 98 |
% implementation came out from |
| 99 |
% \href{https://tex.stackexchange.com/q/40159/14500}{this question} on |
| 100 |
% \href{https://tex.stackexchange.com/}{TeX.StackExchange}. |
| 101 |
% |
| 102 |
% |
| 103 |
% \end{abstract} |
| 104 |
% |
| 105 |
% |
| 106 |
% \manualparts |
| 107 |
% |
| 108 |
% \clearpage |
| 109 |
% |
| 110 |
% \manualparts |
| 111 |
% |
| 112 |
% \begin{quote} |
| 113 |
% {\footnotesize Note: the \code{sankey.dtx} and \code{sankey.ins} |
| 114 |
% files are attachments of the current PDF document.\par} |
| 115 |
% \end{quote} |
| 116 |
% |
| 117 |
%^^A % ------------------------------------------------------------ |
| 118 |
% \part{User manual} |
| 119 |
% \label{usermanual} |
| 120 |
%^^A % ------------------------------------------------------------ |
| 121 |
% |
| 122 |
% \changes{v3.0.2}{2025/10/10}{Update for new version of \protect\code{ltxdoc} class} |
| 123 |
% |
| 124 |
% \changes{v3.0.2}{2025/10/10}{Fixed extra parentheses in some code examples} |
| 125 |
% |
| 126 |
% { |
| 127 |
% \setlength{\parskip}{0pt} |
| 128 |
% \localtableofcontents |
| 129 |
% } |
| 130 |
% |
| 131 |
% \clearpage |
| 132 |
% |
| 133 |
%^^A % ------------------------------------------------------------ |
| 134 |
% \section{Preamble} |
| 135 |
%^^A % ------------------------------------------------------------ |
| 136 |
% |
| 137 |
% To use the \code{sankey} package, insert the following line in your preamble: |
| 138 |
% |
| 139 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 140 |
% \usepackage{sankey} |
| 141 |
% \end{lstlisting} |
| 142 |
% |
| 143 |
% {\small Note: the |
| 144 |
% \code{sankey} package requires automatically the |
| 145 |
% \code{xparse}, \code{etoolbox}, \code{xfp} and |
| 146 |
% \code{tikz} packages, as well as the \code{calc}, |
| 147 |
% \code{decorations.markings} and |
| 148 |
% \code{dubins} (cf. \vref{sec:dubins}) TikZ libraries.\par} |
| 149 |
% |
| 150 |
% |
| 151 |
%^^A % ------------------------------------------------------------ |
| 152 |
% \section{The \ttintitle{sankeydiagram} environment} |
| 153 |
%^^A % ------------------------------------------------------------ |
| 154 |
% |
| 155 |
% \DescribeEnv{sankeydiagram} % |
| 156 |
% A \code{sankeydiagram} environment nested in a \code{tikzpicture} |
| 157 |
% environment activates the sankey macros: |
| 158 |
% |
| 159 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 160 |
% \begin{tikzpicture} |
| 161 |
% \begin{sankeydiagram}[... options ...] |
| 162 |
% ... sankey macros ... |
| 163 |
% \end{sankeydiagram} |
| 164 |
% \end{tikzpicture} |
| 165 |
% \end{lstlisting} |
| 166 |
% |
| 167 |
%^^A % ------------------------------------------------------------ |
| 168 |
% \section{Sankey diagram options} |
| 169 |
%^^A % ------------------------------------------------------------ |
| 170 |
% |
| 171 |
% The \code{sankey} package uses \code{pgfkeys} to set options via |
| 172 |
% \emph{key=value} pairs with default path \code{/sankey} (and |
| 173 |
% \code{/sankey/node parameters} for Sankey node parameters). |
| 174 |
% |
| 175 |
% |
| 176 |
% Options can be defined in three ways: |
| 177 |
% |
| 178 |
% \begin{itemize} |
| 179 |
% \item via the optional argument of the |
| 180 |
% \code{sankeydiagram} environment: |
| 181 |
% |
| 182 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 183 |
% \begin{sankeydiagram}[debug=true] |
| 184 |
% \sankeynode{name=a,quantity=1,angle=0,at={0,0}} |
| 185 |
% \end{sankeydiagram} |
| 186 |
% \end{lstlisting} |
| 187 |
% |
| 188 |
% \item \DescribeMacro{\sankeyset} % |
| 189 |
% via the \code{\sankeyset} macro: |
| 190 |
% |
| 191 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 192 |
% \begin{sankeydiagram} |
| 193 |
% \sankeyset{debug=true} |
| 194 |
% \sankeynode{name=a,quantity=1,angle=0,at={0,0}} |
| 195 |
% \end{sankeydiagram} |
| 196 |
% \end{lstlisting} |
| 197 |
% |
| 198 |
% \item temporarily modified for a single macro: |
| 199 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 200 |
% \begin{sankeydiagram} |
| 201 |
% \sankeynode[debug=true]{name=a,quantity=1,angle=0,at={0,0}} |
| 202 |
% \end{sankeydiagram} |
| 203 |
% \end{lstlisting} |
| 204 |
% |
| 205 |
% \end{itemize} |
| 206 |
% |
| 207 |
% At the begining of each Sankey diagram, all options are initialized |
| 208 |
% with initial values then the \code{every diagram} style is applied. |
| 209 |
% |
| 210 |
% \begin{sankeyoption}{every diagram}{}{}{empty} |
| 211 |
% This style is installed at beginning of each Sankey diagram. |
| 212 |
% \end{sankeyoption} |
| 213 |
% |
| 214 |
% For instance, to use a ratio of 5mm/10 by default (instead of 1cm/10) |
| 215 |
% for all Sankey diagrams, add the following line: |
| 216 |
% |
| 217 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 218 |
% \sankeyset{every diagram/.style={ratio=5mm/10}} |
| 219 |
% \end{lstlisting} |
| 220 |
% |
| 221 |
%^^A % ------------------------------------------------------------ |
| 222 |
% \subsection{Keys to choose the scale} |
| 223 |
%^^A % ------------------------------------------------------------ |
| 224 |
% |
| 225 |
% The scale or ratio of the Sankey diagram is the ratio between the % |
| 226 |
% \code{ratio length} and the \code{ratio quantity}. |
| 227 |
% |
| 228 |
% \begin{sankeyoption}{ratio quantity}{\VAR{number}}{}{10} |
| 229 |
% Quantity (in units of flow) to define ratio. The \VAR{number} can be |
| 230 |
% any math expression. |
| 231 |
% \end{sankeyoption} |
| 232 |
% |
| 233 |
% \begin{sankeyoption}{ratio length}{\VAR{distance}}{}{1cm} |
| 234 |
% Distance (a graphical distance) to define scale. |
| 235 |
% \end{sankeyoption} |
| 236 |
% |
| 237 |
% \begin{sankeyoption}{ratio}{\VAR{distance}/\VAR{number}}{}{1cm/10} |
| 238 |
% Fix the ratio to \VAR{distance}\texttt{/}\VAR{number}. |
| 239 |
% \end{sankeyoption} |
| 240 |
% |
| 241 |
% The initial ratio is 1\,cm/10 units. |
| 242 |
% |
| 243 |
% |
| 244 |
% \textbf{Note:} the \code{sankey} package uses the \code{xfp} package to |
| 245 |
% evaluate all math expressions that use quantities (in units of |
| 246 |
% flow). You can therefore use quantities of a very large or very small |
| 247 |
% order of magnitude. In contrast, for graphic distances, the sankey |
| 248 |
% package uses the \code{pgfmath} package (all calculations must not |
| 249 |
% exceed $\pm 16383.99999$). |
| 250 |
% |
| 251 |
%^^A % ------------------------------------------------------------ |
| 252 |
% \subsection{Keys to define rotate offset} |
| 253 |
%^^A % ------------------------------------------------------------ |
| 254 |
% |
| 255 |
% \begin{sankeyoption}{rotate}{\VAR{angle}}{}{0} |
| 256 |
% |
| 257 |
% The \code{rotate} key stores an offset angle applied to all Sankey |
| 258 |
% nodes. This is useful when using the \code{rotate} option within a |
| 259 |
% \code{tikzpicture} or a \code{scope}. This TikZ option is only |
| 260 |
% applied to coordinates and not to TikZ nodes (remember that Sankey |
| 261 |
% nodes are TikZ nodes). It's up to the author to keep the |
| 262 |
% \code{rotate} option of the \code{tikzpicture} and that of the |
| 263 |
% \code{sankeydiagram} synchronous. |
| 264 |
% |
| 265 |
% \end{sankeyoption} |
| 266 |
% |
| 267 |
%^^A % ------------------------------------------------------------ |
| 268 |
% \subsection{Keys to define drawing parameters} |
| 269 |
%^^A % ------------------------------------------------------------ |
| 270 |
% |
| 271 |
% \begin{sankeyoption}{minimum radius}{\VAR{distance}}{}{5mm} |
| 272 |
% The minimum radius used by \code{\sankeyturn} and |
| 273 |
% \code{\sankeydubins}. |
| 274 |
% \end{sankeyoption} |
| 275 |
% |
| 276 |
% \begin{sankeyoption}{outin steps}{\VAR{integer}}{}{10} |
| 277 |
% Number of steps used by the \code{\sankeyoutin} macro to simulate flow |
| 278 |
% lanes with constant width. |
| 279 |
% \end{sankeyoption} |
| 280 |
% |
| 281 |
%^^A % ------------------------------------------------------------ |
| 282 |
% \subsection{Keys to choose drawing styles} |
| 283 |
%^^A % ------------------------------------------------------------ |
| 284 |
% |
| 285 |
% \begin{sankeyoption}{fill/.style}{\VAR{style}}{}{{line width=0pt,fill=white}} |
| 286 |
% This TikZ style is used to \emph{fill} all sankey paths. |
| 287 |
% \end{sankeyoption} |
| 288 |
% |
| 289 |
% \begin{sankeyoption}{draw/.style}{\VAR{style}}{}{draw=black,line width=.4pt} |
| 290 |
% This TikZ style is used to \emph{draw} all sankey paths. |
| 291 |
% \end{sankeyoption} |
| 292 |
% |
| 293 |
% \begin{sankeyoption}{start style}{\VAR{style name}}{}{none} |
| 294 |
% There are three predefined \emph{start} styles: \constant{none}, |
| 295 |
% \constant{simple}, \constant{arrow}. |
| 296 |
% \end{sankeyoption} |
| 297 |
% |
| 298 |
% \begin{sankeyoption}{end style}{\VAR{style name}}{}{none} |
| 299 |
% There are three predefined \emph{end} styles: \constant{none}, |
| 300 |
% \constant{simple}, \constant{arrow}. |
| 301 |
% \end{sankeyoption} |
| 302 |
% |
| 303 |
%^^A % ------------------------------------------------------------ |
| 304 |
% \subsection{Keys to define new \emph{start} and \emph{end} styles} |
| 305 |
%^^A % ------------------------------------------------------------ |
| 306 |
% |
| 307 |
% \begin{sankeyoption}{new start style}{\{\VAR{name}\}\{\VAR{fill |
| 308 |
% path}\}\{\VAR{draw path}\}}{}{} |
| 309 |
% Define the new start style named \VAR{name} with its \VAR{fill |
| 310 |
% path} and its \VAR{draw path}. |
| 311 |
% \end{sankeyoption} |
| 312 |
% |
| 313 |
% \begin{sankeyoption}{new end style}{\{\VAR{name}\}\{\VAR{fill |
| 314 |
% path}\}\{\VAR{draw path}\}}{}{} |
| 315 |
% Define the new end style named \VAR{name} with its \VAR{fill |
| 316 |
% path} and its \VAR{draw path}. |
| 317 |
% \end{sankeyoption} |
| 318 |
% |
| 319 |
% The \VAR{fill path} and the \VAR{draw path} are build in a TikZ scope |
| 320 |
% where the origin is the center of the current Sankey node (its name is |
| 321 |
% accessible via \code{\name}) and the coordinate system is rotated by |
| 322 |
% its orientation. |
| 323 |
% |
| 324 |
%^^A % ------------------------------------------------------------ |
| 325 |
% \subsection{The \emph{debug} key} |
| 326 |
%^^A % ------------------------------------------------------------ |
| 327 |
% |
| 328 |
% \begin{sankeyoption}{debug}{\VAR{boolean}}{true}{false} |
| 329 |
% To debug a sankey diagram. |
| 330 |
% \end{sankeyoption} |
| 331 |
% |
| 332 |
%^^A % ------------------------------------------------------------ |
| 333 |
% \section{Sankey nodes and flows} |
| 334 |
%^^A % ------------------------------------------------------------ |
| 335 |
% |
| 336 |
%^^A % ------------------------------------------------------------ |
| 337 |
% \subsection{Create Sankey nodes} |
| 338 |
%^^A % ------------------------------------------------------------ |
| 339 |
% |
| 340 |
%^^A % ------------------------------------------------------------ |
| 341 |
% |
| 342 |
% \begin{miniblock} |
| 343 |
% \DescribeMacro{\sankeynode} % |
| 344 |
% \MACRO\code{\sankeynode}\OPTARG{\VAR{options}}\ARG{\VAR{node parameters}} |
| 345 |
% |
| 346 |
% The \code{\sankeynode} macro defines a Sankey node. The \VAR{options} |
| 347 |
% can be any Sankey diagram keys. To define a Sankey node, you must |
| 348 |
% provide a \emph{name}, a \emph{quantity} and an \emph{angle} as |
| 349 |
% \VAR{node parameters}. |
| 350 |
% |
| 351 |
% \begin{sankeyoption}[/sankey/node parameters]{name}{\VAR{name}}{}{} |
| 352 |
% The \VAR{name} of the new Sankey node (and the associated TikZ node). |
| 353 |
% \end{sankeyoption} |
| 354 |
% |
| 355 |
% \begin{sankeyoption}[/sankey/node parameters]{quantity}{\VAR{quantity}}{}{} |
| 356 |
% The quantity (in flow unit) of the new Sankey node. The \VAR{quantity} |
| 357 |
% can be any math expression. |
| 358 |
% \end{sankeyoption} |
| 359 |
% |
| 360 |
% \begin{sankeyoption}[/sankey/node parameters]{angle}{\VAR{angle}}{}{} |
| 361 |
% The orientation of the flow (0 points to the right) of the new Sankey |
| 362 |
% node. |
| 363 |
% \end{sankeyoption} |
| 364 |
% |
| 365 |
% \begin{sankeyoption}[/sankey/node parameters]{at}{\VAR{at}}{}{0,0} |
| 366 |
% The position of the new Sankey node (a TikZ coordinate |
| 367 |
% \textbf{without} round brackets or parentheses). |
| 368 |
% \end{sankeyoption} |
| 369 |
% |
| 370 |
% \begin{sankeyoption}[/sankey/node parameters]{anchor}{\VAR{anchor}}{}{center} |
| 371 |
% Specify the anchor of the Sankey node. Possible values are |
| 372 |
% \constant{center}, \constant{left} or \constant{right}. |
| 373 |
% \end{sankeyoption} |
| 374 |
% |
| 375 |
% \begin{sankeyoption}[/sankey/node parameters]{as}{\VAR{name}}{}{} |
| 376 |
% Copy the \emph{name}, the \emph{quantity}, the \emph{angle} and the |
| 377 |
% \emph{position} of the Sankey node named \VAR{name}. |
| 378 |
% \end{sankeyoption} |
| 379 |
% |
| 380 |
% A Sankey node is also a Tikz node but with only three anchors: |
| 381 |
% \code{left}, \code{center} and \code{right}\footnote{In fact, to be |
| 382 |
% able to use the TikZ \code{fit} library, the % |
| 383 |
% \code{north}, \code{north east} and \code{north west} anchors exist |
| 384 |
% and are equal to \code{left}, % |
| 385 |
% the \code{east} and \code{west} anchors exist and are equal to |
| 386 |
% \code{center} and % |
| 387 |
% the \code{south}, \code{south east} and \code{south west} anchors |
| 388 |
% exist and are equal to \code{right}.}: |
| 389 |
% |
| 390 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 391 |
% \begin{tikzpicture} |
| 392 |
% \begin{sankeydiagram}[debug] |
| 393 |
% \sankeynode{name=a,quantity=10} |
| 394 |
% \sankeynode{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 395 |
% \sankeynode{name=c,quantity=20,angle=-90,at={5,0},anchor=right} |
| 396 |
% \foreach \nodename/\pos in {a/left,b/below left,c/above}{ |
| 397 |
% \foreach \ancname in {left,center,right}{ |
| 398 |
% \node[node font=\ttfamily\footnotesize,\pos=1mm of \nodename.\ancname, |
| 399 |
% inner sep=0pt,rotate=\sankeygetnodeorient{\nodename},anchor=east] |
| 400 |
% {\ancname\vphantom{g}}; |
| 401 |
% \fill[black] (\nodename.\ancname) circle(1pt); |
| 402 |
% } |
| 403 |
% } |
| 404 |
% \end{sankeydiagram} |
| 405 |
% \end{tikzpicture} |
| 406 |
% \end{VerbatimOut} |
| 407 |
% % |
| 408 |
% {\centering\input{\samplecodename}\par} |
| 409 |
% % |
| 410 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 411 |
% \end{miniblock} |
| 412 |
% |
| 413 |
%^^A % \clearpage |
| 414 |
% |
| 415 |
%^^A % ------------------------------------------------------------ |
| 416 |
% \subsubsection{Choose default parameters} |
| 417 |
%^^A % ------------------------------------------------------------ |
| 418 |
% |
| 419 |
% \begin{sankeyoption}{every node/.style}{\{\VAR{node parameters}\}}{}{empty} |
| 420 |
% The \VAR{node parameters} defined by the |
| 421 |
% \code{every node} style is installed at the creation of every Sankey node. |
| 422 |
% \end{sankeyoption} |
| 423 |
% |
| 424 |
%^^A % ------------------------------------------------------------ |
| 425 |
% \subsubsection{Create starting and ending nodes via macros} |
| 426 |
%^^A % ------------------------------------------------------------ |
| 427 |
% |
| 428 |
% \begin{miniblock} |
| 429 |
% \DescribeMacro{\sankeynodestart} % |
| 430 |
% \MACRO\code{\sankeynodestart}\OPTARG{\VAR{options}}\ARG{\VAR{node parameters}} |
| 431 |
% |
| 432 |
% The \code{\sankeynodestart} creates and fills/draws a starting Sankey |
| 433 |
% node: |
| 434 |
% |
| 435 |
% |
| 436 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 437 |
% \begin{tikzpicture} |
| 438 |
% \begin{sankeydiagram}[start style=arrow,fill/.style={fill=orange!20}] |
| 439 |
% \sankeynodestart{name=a,quantity=10} |
| 440 |
% \sankeynodestart{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 441 |
% \sankeynodestart{name=c,quantity=20,angle=-90,at={5,1},anchor=right} |
| 442 |
% \end{sankeydiagram} |
| 443 |
% \end{tikzpicture} |
| 444 |
% \end{VerbatimOut} |
| 445 |
% % |
| 446 |
% {\centering\input{\samplecodename}\par} |
| 447 |
% % |
| 448 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 449 |
% \end{miniblock} |
| 450 |
%^^A % ------------------------------------------------------------ |
| 451 |
% |
| 452 |
% |
| 453 |
% \begin{miniblock} |
| 454 |
% \DescribeMacro{\sankeynodeend} % |
| 455 |
% \MACRO\code{\sankeynodeend}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 456 |
% parameters}} |
| 457 |
% |
| 458 |
% The \code{\sankeynodeend} creates and fills/draws an ending Sankey |
| 459 |
% node: |
| 460 |
% |
| 461 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 462 |
% \begin{tikzpicture} |
| 463 |
% \begin{sankeydiagram}[end style=simple,fill/.style={fill=orange!20}] |
| 464 |
% \sankeynodeend{name=a,quantity=10} |
| 465 |
% \sankeynodeend{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 466 |
% \sankeynodeend{name=c,quantity=20,angle=-90,at={5,1},anchor=right} |
| 467 |
% \end{sankeydiagram} |
| 468 |
% \end{tikzpicture} |
| 469 |
% \end{VerbatimOut} |
| 470 |
% % |
| 471 |
% {\centering\input{\samplecodename}\par} |
| 472 |
% % |
| 473 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 474 |
% \end{miniblock} |
| 475 |
% |
| 476 |
%^^A % ------------------------------------------------------------ |
| 477 |
% \subsubsection{Create starting and ending nodes via options} |
| 478 |
%^^A % ------------------------------------------------------------ |
| 479 |
% |
| 480 |
% \begin{miniblock} |
| 481 |
% \begin{sankeyoption}[/sankey/node parameters]{start}{\VAR{boolean}}{true}{false} |
| 482 |
% The \code{\sankeynode} macro acts as the |
| 483 |
% \code{\sankeynodestart} macro if you add the |
| 484 |
% \code{start} option to its options. |
| 485 |
% \end{sankeyoption} |
| 486 |
% |
| 487 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 488 |
% \begin{tikzpicture} |
| 489 |
% \begin{sankeydiagram}[start style=arrow,fill/.style={fill=orange!20}] |
| 490 |
% \sankeynode{name=a,quantity=10,start} |
| 491 |
% \sankeynode{name=b,quantity=5,angle=45,at={2,1},anchor=left,start} |
| 492 |
% \sankeynode{name=c,quantity=20,angle=-90,at={5,1},anchor=right,start} |
| 493 |
% \end{sankeydiagram} |
| 494 |
% \end{tikzpicture} |
| 495 |
% \end{VerbatimOut} |
| 496 |
% % |
| 497 |
% {\centering\input{\samplecodename}\par} |
| 498 |
% % |
| 499 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 500 |
% \end{miniblock} |
| 501 |
% |
| 502 |
% \begin{miniblock} |
| 503 |
% \begin{sankeyoption}[/sankey/node parameters]{end}{\VAR{boolean}}{true}{false} |
| 504 |
% The \code{\sankeynode} macro acts as the \code{\sankeynodeend} |
| 505 |
% macro if you add the \code{end} option to its options. |
| 506 |
% \end{sankeyoption} |
| 507 |
% |
| 508 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 509 |
% \begin{tikzpicture} |
| 510 |
% \begin{sankeydiagram}[end style=simple,fill/.style={fill=orange!20}] |
| 511 |
% \sankeynode{name=a,quantity=10,end} |
| 512 |
% \sankeynode{name=b,quantity=5,angle=45,at={2,1},anchor=left,end} |
| 513 |
% \sankeynode{name=c,quantity=20,angle=-90,at={5,1},anchor=right,end} |
| 514 |
% \end{sankeydiagram} |
| 515 |
% \end{tikzpicture} |
| 516 |
% \end{VerbatimOut} |
| 517 |
% % |
| 518 |
% {\centering\input{\samplecodename}\par} |
| 519 |
% % |
| 520 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 521 |
% \end{miniblock} |
| 522 |
% |
| 523 |
% |
| 524 |
% \begin{miniblock} |
| 525 |
% Although rarely necessary, you can mix these two parameters: |
| 526 |
% |
| 527 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 528 |
% \begin{tikzpicture} |
| 529 |
% \begin{sankeydiagram} |
| 530 |
% \sankeyset{ |
| 531 |
% end style=arrow, |
| 532 |
% start style=arrow, |
| 533 |
% fill/.style={fill=orange!20} |
| 534 |
% } |
| 535 |
% \sankeynode{name=a,quantity=10,start,end} |
| 536 |
% \sankeynode{name=b,quantity=5,angle=45,at={2,1},anchor=left,start,end} |
| 537 |
% \sankeynode{name=c,quantity=20,angle=-90,at={5,1},anchor=right,start,end} |
| 538 |
% \end{sankeydiagram} |
| 539 |
% \end{tikzpicture} |
| 540 |
% \end{VerbatimOut} |
| 541 |
% % |
| 542 |
% {\centering\input{\samplecodename}\par} |
| 543 |
% % |
| 544 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 545 |
% |
| 546 |
% \end{miniblock} |
| 547 |
% |
| 548 |
%^^A % ------------------------------------------------------------ |
| 549 |
% \subsection{Retrieve information from Sankey nodes} |
| 550 |
%^^A % ------------------------------------------------------------ |
| 551 |
% |
| 552 |
% \DescribeMacro{\sankeygetnodeqty} % |
| 553 |
% \MACRO\code{\sankeygetnodeqty}\ARG{\VAR{node name}} |
| 554 |
% |
| 555 |
% The expandable command \code{\sankeygetnodeqty} returns the quantity |
| 556 |
% assigned to the Sankey node named \VAR{node name}. |
| 557 |
% |
| 558 |
% \DescribeMacro{\sankeyqtytolen} % |
| 559 |
% \MACRO\code{\sankeyqtytolen}\ARG{\VAR{quantity}} |
| 560 |
% |
| 561 |
% The expandable \code{\sankeyqtytolen} macro converts \VAR{quantity} to |
| 562 |
% graphical length using the current ratio. |
| 563 |
% |
| 564 |
% \DescribeMacro{\sankeygetnodeorient} % |
| 565 |
% \MACRO\code{\sankeygetnodeorient}\ARG{\VAR{node name}} |
| 566 |
% |
| 567 |
% The expandable command \code{\sankeygetnodeorient} returns the angle |
| 568 |
% (orientation) assigned to the Sankey node named \VAR{node name}. |
| 569 |
% |
| 570 |
%^^A % ------------------------------------------------------------ |
| 571 |
% \subsection{Move nodes} |
| 572 |
%^^A % ------------------------------------------------------------ |
| 573 |
% |
| 574 |
% All the macros of this section move a Sankey node and fill/draw a |
| 575 |
% portion of the Sankey flow. Then the previous position of the Sankey |
| 576 |
% node is accessible via the \code{-old} suffix (i.e. if you move the |
| 577 |
% \code{a} node, its previous position is the \code{a-old} node). |
| 578 |
% |
| 579 |
% The starred version of each of these macros moves in the opposite |
| 580 |
% direction to their non-starred version. |
| 581 |
% |
| 582 |
% Except for the \code{\sankeyturn} macro, a negative value (distance or |
| 583 |
% angle) moves in the opposite direction (the \code{\sankeyturn} macro |
| 584 |
% is an exception: a negative angle turns right while a positive value |
| 585 |
% turns left). |
| 586 |
% |
| 587 |
% {\centering |
| 588 |
% \begin{tikzpicture} |
| 589 |
% \begin{sankeydiagram} |
| 590 |
% \tikzset{com/.style={node font=\ttfamily\scriptsize, |
| 591 |
% fill=bgcode,fill opacity=1,text opacity=1}} |
| 592 |
% \sankeyset{end style=simple,start style=simple} |
| 593 |
% \sankeynode{name=ac,quantity=5} |
| 594 |
% \sankeynode{name=al,quantity=5,at={[yshift=2mm]ac.left},anchor=right} |
| 595 |
% \sankeynode{name=ar,quantity=5,at={[yshift=-2mm]ac.right},anchor=left} |
| 596 |
% \sankeyturnleft{al}{60} |
| 597 |
% \sankeyadvance{ac}{1cm} |
| 598 |
% \sankeyturnright{ar}{60} |
| 599 |
% \sankeyturnleft*{al-old}{60} |
| 600 |
% \sankeyadvance*{ac-old}{1cm} |
| 601 |
% \sankeyturnright*{ar-old}{60} |
| 602 |
% \sankeystart{al-old} |
| 603 |
% \sankeystart{ac-old} |
| 604 |
% \sankeystart{ar-old} |
| 605 |
% \sankeyend{al} |
| 606 |
% \sankeyend{ac} |
| 607 |
% \sankeyend{ar} |
| 608 |
% \draw[red,very thick] |
| 609 |
% (al-old-old.left) -- node[com]{n} (al-old-old.right) |
| 610 |
% (ac-old-old.left) -- node[com]{n} (ac-old-old.right) |
| 611 |
% (ar-old-old.left) -- node[com]{n} (ar-old-old.right); |
| 612 |
% \path |
| 613 |
% (al) ++(2mm,2mm) node[com,anchor=south west,align=left] { |
| 614 |
% \string\sankeyturnleft\{n\}\{angle>0\}\\ |
| 615 |
% \string\sankeyturnleftbackward\{n\}\{angle<0\}\\ |
| 616 |
% \string\sankeyturnleft*\{n\}\{angle<0\}\\ |
| 617 |
% \string\sankeyturnleftbackward*\{n\}\{angle>0\}\\ |
| 618 |
% \string\sankeyturn\{n\}\{angle>0\} |
| 619 |
% }; |
| 620 |
% \path |
| 621 |
% (al-old) ++(-2mm,2mm) node[com,anchor=south east,align=right] { |
| 622 |
% \string\sankeyturnleftbackward\{n\}\{angle>0\}\\ |
| 623 |
% \string\sankeyturnleft\{n\}\{angle<0\}\\ |
| 624 |
% \string\sankeyturnleft*\{n\}\{angle>0\}\\ |
| 625 |
% \string\sankeyturnleftbackward*\{n\}\{angle<0\}\\ |
| 626 |
% \string\sankeyturn*\{n\}\{angle>0\} |
| 627 |
% }; |
| 628 |
% \path |
| 629 |
% (ac) ++(2mm,0) node[com,anchor=west,align=left] { |
| 630 |
% \string\sankeyadvance\{n\}\{distance>0\}\\ |
| 631 |
% \string\sankeyadvance*\{n\}\{distance<0\} |
| 632 |
% }; |
| 633 |
% \path |
| 634 |
% (ac-old) ++(-2mm,0) node[com,anchor=east,align=right] { |
| 635 |
% \string\sankeyadvance\{n\}\{distance<0\}\\ |
| 636 |
% \string\sankeyadvance*\{n\}\{distance>0\} |
| 637 |
% }; |
| 638 |
% \path |
| 639 |
% (ar) ++(2mm,-2mm) node[com,anchor=north west,align=left] { |
| 640 |
% \string\sankeyturnright\{n\}\{angle>0\}\\ |
| 641 |
% \string\sankeyturnrightbackward\{n\}\{angle<0\}\\ |
| 642 |
% \string\sankeyturnright*\{n\}\{angle<0\}\\ |
| 643 |
% \string\sankeyturnrightbackward*\{n\}\{angle>0\}\\ |
| 644 |
% \string\sankeyturn\{n\}\{angle<0\} |
| 645 |
% }; |
| 646 |
% \path |
| 647 |
% (ar-old) ++(-2mm,-2mm) node[com,anchor=north east,align=right] { |
| 648 |
% \string\sankeyturnrightbackward\{n\}\{angle>0\}\\ |
| 649 |
% \string\sankeyturnright\{n\}\{angle<0\}\\ |
| 650 |
% \string\sankeyturnright*\{n\}\{angle>0\}\\ |
| 651 |
% \string\sankeyturnrightbackward*\{n\}\{angle<0\}\\ |
| 652 |
% \string\sankeyturn*\{n\}\{angle<0\} |
| 653 |
% }; |
| 654 |
% \end{sankeydiagram} |
| 655 |
% \end{tikzpicture} |
| 656 |
% \par} |
| 657 |
%^^A % ------------------------------------------------------------ |
| 658 |
% \subsubsection{Macro to move straight (forward or backward)} |
| 659 |
%^^A % ------------------------------------------------------------ |
| 660 |
% |
| 661 |
% |
| 662 |
% \begin{miniblock} |
| 663 |
% \DescribeMacro{\sankeyadvance} % |
| 664 |
% \MACRO\code{\sankeyadvance}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 665 |
% name}}\ARG{\VAR{distance}} |
| 666 |
% |
| 667 |
% The \code{\sankeyadvance} moves the sankey node straight ahead and |
| 668 |
% fills/draws this portion of the sankey path. A positive |
| 669 |
% \VAR{distance} moves forward while a negative \VAR{distance} moves |
| 670 |
% backward. |
| 671 |
% |
| 672 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 673 |
% \begin{tikzpicture} |
| 674 |
% \begin{sankeydiagram}[start style=arrow,fill/.style={fill=orange!20}] |
| 675 |
% \sankeynodestart{name=a,quantity=10} |
| 676 |
% \sankeyadvance{a}{1cm} |
| 677 |
% \sankeynode[debug]{as=a} |
| 678 |
% \sankeynode[debug]{as=a-old} |
| 679 |
% \sankeynodestart{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 680 |
% \sankeyadvance{b}{1cm} |
| 681 |
% \sankeynodestart{name=c,quantity=10,angle=-90,at={5,1},anchor=right} |
| 682 |
% \sankeyadvance{c}{5mm} |
| 683 |
% \fill[cyan] (0,0) circle(2pt) (2,1) circle(2pt) (5,1) circle(2pt); |
| 684 |
% \end{sankeydiagram} |
| 685 |
% \end{tikzpicture} |
| 686 |
% \end{VerbatimOut} |
| 687 |
% % |
| 688 |
% {\centering\input{\samplecodename}\par} |
| 689 |
% % |
| 690 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 691 |
% \end{miniblock} |
| 692 |
% |
| 693 |
% \begin{miniblock} |
| 694 |
% \MACRO\code{\sankeyadvance*}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 695 |
% name}}\ARG{\VAR{distance}} |
| 696 |
% |
| 697 |
% The |
| 698 |
% \code{\sankeyadvance*} moves the sankey node straight back and fills/draws this portion of the sankey path. A positive \VAR{distance} moves backward while a negative \VAR{distance} moves forward. |
| 699 |
% |
| 700 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 701 |
% \begin{tikzpicture} |
| 702 |
% \begin{sankeydiagram}[end style=arrow,fill/.style={fill=orange!20}] |
| 703 |
% \sankeynodeend{name=a,quantity=10} |
| 704 |
% \sankeyadvance*{a}{1cm} |
| 705 |
% \sankeynode[debug]{as=a} |
| 706 |
% \sankeynode[debug]{as=a-old} |
| 707 |
% \sankeynodeend{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 708 |
% \sankeyadvance*{b}{1cm} |
| 709 |
% \sankeynodeend{name=c,quantity=10,angle=-90,at={5,1},anchor=right} |
| 710 |
% \sankeyadvance*{c}{5mm} |
| 711 |
% \fill[cyan] (0,0) circle(2pt) (2,1) circle(2pt) (5,1) circle(2pt); |
| 712 |
% \end{sankeydiagram} |
| 713 |
% \end{tikzpicture} |
| 714 |
% \end{VerbatimOut} |
| 715 |
% % |
| 716 |
% {\centering\input{\samplecodename}\par} |
| 717 |
% % |
| 718 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 719 |
% \end{miniblock} |
| 720 |
% |
| 721 |
%^^A % ------------------------------------------------------------ |
| 722 |
% \subsubsection{Macro to turn forward or backward} |
| 723 |
%^^A % ------------------------------------------------------------ |
| 724 |
% |
| 725 |
%\begin{miniblock} |
| 726 |
% \DescribeMacro{\sankeyturn} % |
| 727 |
% \MACRO\code{\sankeyturn}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 728 |
% name}}\ARG{\VAR{angle}} |
| 729 |
% |
| 730 |
% The \code{\sankeyturn} macro moves the |
| 731 |
% sankey node by turning to one side or the other and fills/draws |
| 732 |
% this portion of the sankey path. A \emph{positive} \VAR{angle} |
| 733 |
% turns left while a \emph{negative} \VAR{angle} turns right. |
| 734 |
% |
| 735 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 736 |
% \begin{tikzpicture} |
| 737 |
% \begin{sankeydiagram}[start style=arrow,fill/.style={fill=orange!20}] |
| 738 |
% \sankeynodestart{name=a,quantity=10} |
| 739 |
% \sankeyturn{a}{90} |
| 740 |
% \sankeynode[debug]{as=a} |
| 741 |
% \sankeynode[debug]{as=a-old} |
| 742 |
% \sankeynodestart{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 743 |
% \sankeyturn[minimum radius=1cm]{b}{-45} |
| 744 |
% \sankeynodestart{name=c,quantity=10,angle=-90,at={5,1},anchor=right} |
| 745 |
% \sankeyturn{c}{180} |
| 746 |
% \fill[cyan] (0,0) circle(2pt) (2,1) circle(2pt) (5,1) circle(2pt); |
| 747 |
% \end{sankeydiagram} |
| 748 |
% \end{tikzpicture} |
| 749 |
% \end{VerbatimOut} |
| 750 |
% |
| 751 |
% {\centering\input{\samplecodename}\par} |
| 752 |
% % |
| 753 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 754 |
% \end{miniblock} |
| 755 |
% |
| 756 |
% \begin{miniblock} |
| 757 |
% \MACRO\code{\sankeyturn*}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 758 |
% name}}\ARG{\VAR{angle}} |
| 759 |
% |
| 760 |
% The \code{\sankeyturn*} macro moves the |
| 761 |
% sankey node backward by turning right or left and fills/draws this |
| 762 |
% portion of the sankey path. A \emph{positive} \VAR{angle} turns left |
| 763 |
% while a \emph{negative} \VAR{angle} turns right. |
| 764 |
% |
| 765 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 766 |
% \begin{tikzpicture} |
| 767 |
% \begin{sankeydiagram}[end style=simple,fill/.style={fill=orange!20}] |
| 768 |
% \sankeynodeend{name=a,quantity=10} |
| 769 |
% \sankeyturn*{a}{90} |
| 770 |
% \sankeynode[debug]{as=a} |
| 771 |
% \sankeynode[debug]{as=a-old} |
| 772 |
% \sankeynodeend{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 773 |
% \sankeyturn*[minimum radius=1cm]{b}{-45} |
| 774 |
% \sankeynodeend{name=c,quantity=10,angle=-90,at={3,1},anchor=right} |
| 775 |
% \sankeyturn*{c}{180} |
| 776 |
% \fill[cyan] (0,0) circle(2pt) (2,1) circle(2pt) (3,1) circle(2pt); |
| 777 |
% \end{sankeydiagram} |
| 778 |
% \end{tikzpicture} |
| 779 |
% \end{VerbatimOut} |
| 780 |
% % |
| 781 |
% {\centering\input{\samplecodename}\par} |
| 782 |
% % |
| 783 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 784 |
% \end{miniblock} |
| 785 |
% |
| 786 |
%^^A % ------------------------------------------------------------ |
| 787 |
% \subsubsection{Macros to turn left (forward or backward)} |
| 788 |
%^^A % ------------------------------------------------------------ |
| 789 |
% |
| 790 |
% \begin{miniblock} |
| 791 |
% \DescribeMacro{\sankeyturnleft} % |
| 792 |
% \MACRO\code{\sankeyturnleft}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 793 |
% name}}\ARG{\VAR{angle}} |
| 794 |
% |
| 795 |
% The \code{\sankeyturnleft} macro moves the sankey node by turning |
| 796 |
% left and fills/draws this portion of the sankey path. A |
| 797 |
% \emph{positive} \VAR{angle} turns forward while a \emph{negative} |
| 798 |
% \VAR{angle} turns backward. |
| 799 |
% |
| 800 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 801 |
% \begin{tikzpicture} |
| 802 |
% \begin{sankeydiagram}[start style=arrow,end style=arrow] |
| 803 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 804 |
% \sankeynodestart{name=a,quantity=10} |
| 805 |
% \sankeyturnleft{a}{90} |
| 806 |
% \sankeynode[debug]{as=a} |
| 807 |
% \sankeynode[debug]{as=a-old} |
| 808 |
% \sankeyset{fill/.style={fill=lime!20}} |
| 809 |
% \sankeynodeend{name=b,quantity=5,angle=-135,at={1,2},anchor=left} |
| 810 |
% \sankeyturnleft[minimum radius=1cm]{b}{-225} |
| 811 |
% \fill[cyan] (0,0) circle(2pt) (1,2) circle(2pt); |
| 812 |
% \end{sankeydiagram} |
| 813 |
% \end{tikzpicture} |
| 814 |
% \end{VerbatimOut} |
| 815 |
% |
| 816 |
% {\centering\input{\samplecodename}\par} |
| 817 |
% % |
| 818 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 819 |
% \end{miniblock} |
| 820 |
% |
| 821 |
% \begin{miniblock} |
| 822 |
% \MACRO\code{\sankeyturnleft*}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 823 |
% name}}\ARG{\VAR{angle}} |
| 824 |
% |
| 825 |
% The |
| 826 |
% \code{\sankeyturnleft*} macro moves the sankey node backward |
| 827 |
% by turning left and fills/draws this portion of the sankey path. |
| 828 |
% A \emph{positive} \VAR{angle} turns backward while a |
| 829 |
% \emph{negative} \VAR{angle} turns forward. |
| 830 |
% |
| 831 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 832 |
% \begin{tikzpicture} |
| 833 |
% \begin{sankeydiagram}[start style=arrow,end style=arrow] |
| 834 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 835 |
% \sankeynodeend{name=a,quantity=10} |
| 836 |
% \sankeyturnleft*{a}{90} |
| 837 |
% \sankeynode[debug]{as=a} |
| 838 |
% \sankeynode[debug]{as=a-old} |
| 839 |
% \sankeyset{fill/.style={fill=lime!20}} |
| 840 |
% \sankeynodestart{name=b,quantity=5,angle=-135,at={1,2},anchor=left} |
| 841 |
% \sankeyturnleft*[minimum radius=.75cm]{b}{-225} |
| 842 |
% \fill[cyan] (0,0) circle(2pt) (1,2) circle(2pt); |
| 843 |
% \end{sankeydiagram} |
| 844 |
% \end{tikzpicture} |
| 845 |
% \end{VerbatimOut} |
| 846 |
% |
| 847 |
% {\centering\input{\samplecodename}\par} |
| 848 |
% % |
| 849 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 850 |
% \end{miniblock} |
| 851 |
% |
| 852 |
% \begin{miniblock} |
| 853 |
% \DescribeMacro{\sankeyturnleftbackward} % |
| 854 |
% \MACRO\code{\sankeyturnleftbackward}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 855 |
% name}}\ARG{\VAR{angle}} |
| 856 |
% |
| 857 |
% The \code{\sankeyturnleftbackward} macro moves the sankey node |
| 858 |
% backward by turning left and fills/draws this portion of the sankey |
| 859 |
% path. A \emph{positive} \VAR{angle} turns backward while a |
| 860 |
% \emph{negative} \VAR{angle} turns forward. |
| 861 |
% |
| 862 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 863 |
% \begin{tikzpicture} |
| 864 |
% \begin{sankeydiagram}[start style=arrow,end style=arrow] |
| 865 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 866 |
% \sankeynodeend{name=a,quantity=10} |
| 867 |
% \sankeyturnleftbackward{a}{90} |
| 868 |
% \sankeynode[debug]{as=a} |
| 869 |
% \sankeynode[debug]{as=a-old} |
| 870 |
% \sankeyset{fill/.style={fill=lime!20}} |
| 871 |
% \sankeynodestart{name=b,quantity=5,angle=-135,at={1,2},anchor=left} |
| 872 |
% \sankeyturnleftbackward[minimum radius=.75cm]{b}{-225} |
| 873 |
% \fill[cyan] (0,0) circle(2pt) (1,2) circle(2pt); |
| 874 |
% \end{sankeydiagram} |
| 875 |
% \end{tikzpicture} |
| 876 |
% \end{VerbatimOut} |
| 877 |
% |
| 878 |
% {\centering\input{\samplecodename}\par} |
| 879 |
% % |
| 880 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 881 |
% \end{miniblock} |
| 882 |
% |
| 883 |
% \begin{miniblock} |
| 884 |
% \MACRO\code{\sankeyturnleftbackward*}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 885 |
% name}}\ARG{\VAR{angle}} |
| 886 |
% |
| 887 |
% The |
| 888 |
% \code{\sankeyturnleftbackward*} macro moves the sankey node by turning left |
| 889 |
% and fills/draws this portion of the sankey path. A \emph{positive} |
| 890 |
% \VAR{angle} turns forward while a \emph{negative} \VAR{angle} turns backward. |
| 891 |
% |
| 892 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 893 |
% \begin{tikzpicture} |
| 894 |
% \begin{sankeydiagram}[start style=arrow,end style=arrow] |
| 895 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 896 |
% \sankeynodestart{name=a,quantity=10} |
| 897 |
% \sankeyturnleftbackward*{a}{90} |
| 898 |
% \sankeynode[debug]{as=a} |
| 899 |
% \sankeynode[debug]{as=a-old} |
| 900 |
% \sankeyset{fill/.style={fill=lime!20}} |
| 901 |
% \sankeynodeend{name=b,quantity=5,angle=-135,at={1,2},anchor=left} |
| 902 |
% \sankeyturnleftbackward*[minimum radius=1cm]{b}{-225} |
| 903 |
% \fill[cyan] (0,0) circle(2pt) (1,2) circle(2pt); |
| 904 |
% \end{sankeydiagram} |
| 905 |
% \end{tikzpicture} |
| 906 |
% \end{VerbatimOut} |
| 907 |
% |
| 908 |
% {\centering\input{\samplecodename}\par} |
| 909 |
% % |
| 910 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 911 |
% \end{miniblock} |
| 912 |
% |
| 913 |
% |
| 914 |
%^^A % ------------------------------------------------------------ |
| 915 |
% \subsubsection{Macros to turn right (forward or backward)} |
| 916 |
%^^A % ------------------------------------------------------------ |
| 917 |
% |
| 918 |
% \begin{miniblock} |
| 919 |
% \DescribeMacro{\sankeyturnright} % |
| 920 |
% \MACRO\code{\sankeyturnright}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 921 |
% name}}\ARG{\VAR{angle}} |
| 922 |
% |
| 923 |
% The \code{\sankeyturnright} macro moves the sankey node by turning |
| 924 |
% right and fills/draws this portion of the sankey path. A |
| 925 |
% \emph{positive} \VAR{angle} turns forward while a \emph{negative} |
| 926 |
% \VAR{angle} turns backward. |
| 927 |
% |
| 928 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 929 |
% \begin{tikzpicture} |
| 930 |
% \begin{sankeydiagram}[start style=arrow,end style=arrow] |
| 931 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 932 |
% \sankeynodestart{name=a,quantity=10} |
| 933 |
% \sankeyturnright[fill/.style={fill=orange!20}]{a}{90} |
| 934 |
% \sankeynode[debug]{as=a} |
| 935 |
% \sankeynode[debug]{as=a-old} |
| 936 |
% \sankeyset{fill/.style={fill=lime!20}} |
| 937 |
% \sankeynodeend{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 938 |
% \sankeyturnright[minimum radius=.75cm]{b}{-225} |
| 939 |
% \fill[cyan] (0,0) circle(2pt) (2,1) circle(2pt); |
| 940 |
% \end{sankeydiagram} |
| 941 |
% \end{tikzpicture} |
| 942 |
% \end{VerbatimOut} |
| 943 |
% |
| 944 |
% {\centering\input{\samplecodename}\par} |
| 945 |
% % |
| 946 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 947 |
% \end{miniblock} |
| 948 |
% |
| 949 |
% \begin{miniblock} |
| 950 |
% \MACRO\code{\sankeyturnright*}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 951 |
% name}}\ARG{\VAR{angle}} |
| 952 |
% |
| 953 |
% The \code{\sankeyturnright*} macro |
| 954 |
% moves the sankey node backward by turning right and fills/draws |
| 955 |
% this portion of the sankey path. A \emph{positive} \VAR{angle} turns |
| 956 |
% backward while a \emph{negative} \VAR{angle} turns forward. |
| 957 |
% |
| 958 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 959 |
% \begin{tikzpicture} |
| 960 |
% \begin{sankeydiagram}[start style=arrow,end style=arrow] |
| 961 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 962 |
% \sankeynodeend{name=a,quantity=10} |
| 963 |
% \sankeyturnright*[fill/.style={fill=orange!20}]{a}{90} |
| 964 |
% \sankeynode[debug]{as=a} |
| 965 |
% \sankeynode[debug]{as=a-old} |
| 966 |
% \sankeyset{fill/.style={fill=lime!20}} |
| 967 |
% \sankeynodestart{name=b,quantity=5,angle=45,at={1,1},anchor=left} |
| 968 |
% \sankeyturnright*[minimum radius=.75cm]{b}{-225} |
| 969 |
% \fill[cyan] (0,0) circle(2pt) (1,1) circle(2pt); |
| 970 |
% \end{sankeydiagram} |
| 971 |
% \end{tikzpicture} |
| 972 |
% \end{VerbatimOut} |
| 973 |
% |
| 974 |
% {\centering\input{\samplecodename}\par} |
| 975 |
% % |
| 976 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 977 |
% \end{miniblock} |
| 978 |
% |
| 979 |
% \begin{miniblock} |
| 980 |
% \DescribeMacro{\sankeyturnrightbackward} % |
| 981 |
% \MACRO\code{\sankeyturnrightbackward}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 982 |
% name}}\ARG{\VAR{angle}} |
| 983 |
% |
| 984 |
% The \code{\sankeyturnrightbackward} macro |
| 985 |
% moves the sankey node backward by turning right and fills/draws |
| 986 |
% this portion of the sankey path. A \emph{positive} \VAR{angle} turns |
| 987 |
% backward while a \emph{negative} \VAR{angle} turns forward. |
| 988 |
% |
| 989 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 990 |
% \begin{tikzpicture} |
| 991 |
% \begin{sankeydiagram}[start style=arrow,end style=arrow] |
| 992 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 993 |
% \sankeynodeend{name=a,quantity=10} |
| 994 |
% \sankeyturnrightbackward[fill/.style={fill=orange!20}]{a}{90} |
| 995 |
% \sankeynode[debug]{as=a} |
| 996 |
% \sankeynode[debug]{as=a-old} |
| 997 |
% \sankeyset{fill/.style={fill=lime!20}} |
| 998 |
% \sankeynodestart{name=b,quantity=5,angle=45,at={1,1},anchor=left} |
| 999 |
% \sankeyturnrightbackward[minimum radius=.75cm]{b}{-225} |
| 1000 |
% \fill[cyan] (0,0) circle(2pt) (1,1) circle(2pt); |
| 1001 |
% \end{sankeydiagram} |
| 1002 |
% \end{tikzpicture} |
| 1003 |
% \end{VerbatimOut} |
| 1004 |
% |
| 1005 |
% {\centering\input{\samplecodename}\par} |
| 1006 |
% % |
| 1007 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1008 |
% \end{miniblock} |
| 1009 |
% |
| 1010 |
% \begin{miniblock} |
| 1011 |
% \MACRO\code{\sankeyturnrightbackward*}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 1012 |
% name}}\ARG{\VAR{angle}} |
| 1013 |
% |
| 1014 |
% The |
| 1015 |
% \code{\sankeyturnrightbackward*} macro moves the sankey |
| 1016 |
% node forward by turning right and fills/draws this portion |
| 1017 |
% of the sankey path. A \emph{positive} \VAR{angle} turns forward |
| 1018 |
% while a \emph{negative} \VAR{angle} turns backward. |
| 1019 |
% |
| 1020 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1021 |
% \begin{tikzpicture} |
| 1022 |
% \begin{sankeydiagram}[start style=arrow,end style=arrow] |
| 1023 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 1024 |
% \sankeynodestart{name=a,quantity=10} |
| 1025 |
% \sankeyturnrightbackward*[fill/.style={fill=orange!20}]{a}{90} |
| 1026 |
% \sankeynode[debug]{as=a} |
| 1027 |
% \sankeynode[debug]{as=a-old} |
| 1028 |
% \sankeyset{fill/.style={fill=lime!20}} |
| 1029 |
% \sankeynodeend{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 1030 |
% \sankeyturnrightbackward*[minimum radius=.75cm]{b}{-225} |
| 1031 |
% \fill[cyan] (0,0) circle(2pt) (2,1) circle(2pt); |
| 1032 |
% \end{sankeydiagram} |
| 1033 |
% \end{tikzpicture} |
| 1034 |
% \end{VerbatimOut} |
| 1035 |
% |
| 1036 |
% {\centering\input{\samplecodename}\par} |
| 1037 |
% % |
| 1038 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1039 |
% \end{miniblock} |
| 1040 |
% |
| 1041 |
% |
| 1042 |
%^^A % ------------------------------------------------------------ |
| 1043 |
% \subsection{Links between nodes} |
| 1044 |
%^^A % ------------------------------------------------------------ |
| 1045 |
% |
| 1046 |
% The macros described in this section fill/draw a lane between two |
| 1047 |
% Sankey nodes. |
| 1048 |
% |
| 1049 |
% Note: since Sankey nodes are oriented, linking \code{A} node to |
| 1050 |
% \code{B} node does not produce the same result as linking \code{B} |
| 1051 |
% node to \code{A} node! |
| 1052 |
% |
| 1053 |
% \begin{miniblock} |
| 1054 |
% \DescribeMacro{\sankeyoutin} % |
| 1055 |
% \MACRO\code{\sankeyoutin}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 1056 |
% A}}\ARG{\VAR{node B}} |
| 1057 |
% |
| 1058 |
% The \code{\sankeyoutin} macro |
| 1059 |
% fills/draws a lane from \VAR{node A} to \VAR{node B} using a |
| 1060 |
% Bézier curve with regular steps (10 steps by default) to |
| 1061 |
% simulate constant width lane. |
| 1062 |
% |
| 1063 |
% \textbf{Note:} The constant width and the minimum curvature are |
| 1064 |
% \emph{not} guaranteed! |
| 1065 |
% \end{miniblock} |
| 1066 |
% |
| 1067 |
% \begin{miniblock} |
| 1068 |
% \DescribeMacro{\sankeydubins} % |
| 1069 |
% \MACRO\code{\sankeydubins}\OPTARG{\VAR{options}}\ARG{\VAR{node |
| 1070 |
% A}}\ARG{\VAR{node B}} |
| 1071 |
% |
| 1072 |
% The \code{\sankeydubins} macro fills/draws a lane between |
| 1073 |
% \VAR{node A} and \VAR{node B} using a Dubins |
| 1074 |
% path\footnote{\url{https://en.wikipedia.org/wiki/Dubins_path}}. |
| 1075 |
% |
| 1076 |
% \textbf{Note:} The constant width and the minimum curvature are |
| 1077 |
% guaranteed. |
| 1078 |
% \end{miniblock} |
| 1079 |
% |
| 1080 |
% \clearpage |
| 1081 |
% |
| 1082 |
%^^A % ------------------------------------------------------------ |
| 1083 |
% \subsubsection{Comparison between \ttintitle{outin} and \ttintitle{dubins} |
| 1084 |
% paths} |
| 1085 |
%^^A % ------------------------------------------------------------ |
| 1086 |
% |
| 1087 |
% The following diagrams compare \texttt{outin} path with |
| 1088 |
% 10 steps (orange), \texttt{outin} path with 2 steps (red) |
| 1089 |
% and \texttt{dubins} path (lime) in various positions. |
| 1090 |
% |
| 1091 |
% \begin{miniblock} |
| 1092 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1093 |
% \begin{tikzpicture} |
| 1094 |
% \begin{sankeydiagram}[start style=simple,end style=arrow] |
| 1095 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 1096 |
% \sankeynodestart{name=a,quantity=5} |
| 1097 |
% \sankeynodeend{name=b,at={4,3},quantity=5} |
| 1098 |
% \sankeyoutin{a}{b} |
| 1099 |
% |
| 1100 |
% \sankeyset{fill/.style={fill=red!20}} |
| 1101 |
% \sankeynodestart{name=a,at={2,0},quantity=5} |
| 1102 |
% \sankeynodeend{name=b,at={6,3},quantity=5} |
| 1103 |
% \sankeyoutin[outin steps=2]{a}{b} |
| 1104 |
% |
| 1105 |
% \sankeyset{fill/.style={fill=lime!40}} |
| 1106 |
% \sankeynodestart{name=a,at={4,0},quantity=5} |
| 1107 |
% \sankeynodeend{name=b,at={8,3},quantity=5} |
| 1108 |
% \sankeydubins[minimum radius=5mm]{a}{b} |
| 1109 |
% \end{sankeydiagram} |
| 1110 |
% \end{tikzpicture} |
| 1111 |
% \end{VerbatimOut} |
| 1112 |
% % |
| 1113 |
% {\centering\input{\samplecodename}\par} |
| 1114 |
% % |
| 1115 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1116 |
% \end{miniblock} |
| 1117 |
% |
| 1118 |
% \begin{miniblock} |
| 1119 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1120 |
% \begin{tikzpicture} |
| 1121 |
% \begin{sankeydiagram}[start style=simple,end style=arrow] |
| 1122 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 1123 |
% \sankeynodestart{name=a,quantity=5} |
| 1124 |
% \sankeynodeend{name=b,at={2,3},quantity=5} |
| 1125 |
% \sankeyoutin{a}{b} |
| 1126 |
% |
| 1127 |
% \sankeyset{fill/.style={fill=red!20}} |
| 1128 |
% \sankeynodestart{name=a,at={2,0},quantity=5} |
| 1129 |
% \sankeynodeend{name=b,at={4,3},quantity=5} |
| 1130 |
% \sankeyoutin[outin steps=2]{a}{b} |
| 1131 |
% |
| 1132 |
% \sankeyset{fill/.style={fill=lime!40}} |
| 1133 |
% \sankeynodestart{name=a,at={4,0},quantity=5} |
| 1134 |
% \sankeynodeend{name=b,at={6,3},quantity=5} |
| 1135 |
% \sankeydubins[minimum radius=5mm]{a}{b} |
| 1136 |
% \end{sankeydiagram} |
| 1137 |
% \end{tikzpicture} |
| 1138 |
% \end{VerbatimOut} |
| 1139 |
% % |
| 1140 |
% {\centering\input{\samplecodename}\par} |
| 1141 |
% % |
| 1142 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1143 |
% \end{miniblock} |
| 1144 |
% |
| 1145 |
% \begin{miniblock} |
| 1146 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1147 |
% \begin{tikzpicture} |
| 1148 |
% \begin{sankeydiagram}[start style=simple,end style=arrow] |
| 1149 |
% \sankeyset{fill/.style={fill=orange!20}} |
| 1150 |
% \sankeynodestart{name=a,quantity=5} |
| 1151 |
% \sankeynodeend{name=b,at={0,3},quantity=5} |
| 1152 |
% \sankeyoutin{a}{b} |
| 1153 |
% |
| 1154 |
% \sankeyset{fill/.style={fill=red!20}} |
| 1155 |
% \sankeynodestart{name=a,at={2,0},quantity=5} |
| 1156 |
% \sankeynodeend{name=b,at={2,3},quantity=5} |
| 1157 |
% \sankeyoutin[outin steps=2]{a}{b} |
| 1158 |
% |
| 1159 |
% \sankeyset{fill/.style={fill=lime!40}} |
| 1160 |
% \sankeynodestart{name=a,at={4,0},quantity=5} |
| 1161 |
% \sankeynodeend{name=b,at={4,3},quantity=5} |
| 1162 |
% \sankeydubins[minimum radius=5mm]{a}{b} |
| 1163 |
% \end{sankeydiagram} |
| 1164 |
% \end{tikzpicture} |
| 1165 |
% \end{VerbatimOut} |
| 1166 |
% % |
| 1167 |
% {\centering\input{\samplecodename}\par} |
| 1168 |
% % |
| 1169 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1170 |
% \end{miniblock} |
| 1171 |
% |
| 1172 |
%^^A % ------------------------------------------------------------ |
| 1173 |
% \subsubsection{Examples of \ttintitle{dubins} paths} |
| 1174 |
%^^A % ------------------------------------------------------------ |
| 1175 |
% |
| 1176 |
% \begin{miniblock} |
| 1177 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1178 |
% \begin{tikzpicture} |
| 1179 |
% \begin{sankeydiagram}[start style=simple,end style=arrow] |
| 1180 |
% \sankeyset{ |
| 1181 |
% fill/.style={fill=lime!40}, |
| 1182 |
% draw/.style={draw=green!50!black,line width=2pt}, |
| 1183 |
% } |
| 1184 |
% |
| 1185 |
% \sankeynodestart{name=a,quantity=5} |
| 1186 |
% \sankeynodeend{name=b,at={0,2},quantity=5} |
| 1187 |
% \sankeydubins[minimum radius=2mm]{a}{b} |
| 1188 |
% |
| 1189 |
% \fill[green!50!black] (2,0) coordinate (c) circle(2pt); |
| 1190 |
% \sankeynodestart{name=a,at={[shift={(c)}]90:5mm},quantity=5} |
| 1191 |
% \sankeynodeend{name=b,at={[shift={(c)}]150:5mm},angle=60,quantity=5} |
| 1192 |
% \sankeydubins[minimum radius=2.5mm]{a}{b} |
| 1193 |
% |
| 1194 |
% \sankeynodestart{name=a,at={3.5,0},quantity=5} |
| 1195 |
% \sankeynodeend{name=b,at={3.5,.75},angle=-180,quantity=5} |
| 1196 |
% \sankeydubins[minimum radius=5mm]{a}{b} |
| 1197 |
% |
| 1198 |
% \sankeynodestart{name=a,at={7,1},quantity=5} |
| 1199 |
% \sankeynodeend{name=b,at={7,1.75},quantity=5} |
| 1200 |
% \sankeydubins[minimum radius=2.5mm]{a}{b} |
| 1201 |
% |
| 1202 |
% \sankeynodestart{name=a,at={9,0},quantity=5} |
| 1203 |
% \sankeynodeend{name=b,at={9,2},angle=180,quantity=5} |
| 1204 |
% \sankeydubins[minimum radius=2.5mm]{a}{b} |
| 1205 |
% \end{sankeydiagram} |
| 1206 |
% \end{tikzpicture} |
| 1207 |
% \end{VerbatimOut} |
| 1208 |
% % |
| 1209 |
% {\centering\input{\samplecodename}\par} |
| 1210 |
% % |
| 1211 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1212 |
% \end{miniblock} |
| 1213 |
% |
| 1214 |
%^^A % ------------------------------------------------------------ |
| 1215 |
% \subsection{Pure filling/drawing macros} |
| 1216 |
%^^A % ------------------------------------------------------------ |
| 1217 |
% |
| 1218 |
% \begin{miniblock} |
| 1219 |
% \DescribeMacro{\sankeystart} % |
| 1220 |
% \MACRO\code{\sankeystart}\OPTARG{\VAR{options}}\ARG{\VAR{name}} |
| 1221 |
% |
| 1222 |
% The \code{\sankeystart} fills/draws a starting extremity attached to |
| 1223 |
% the preexisting Sankey node \VAR{name}: |
| 1224 |
% |
| 1225 |
% |
| 1226 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1227 |
% \begin{tikzpicture} |
| 1228 |
% \begin{sankeydiagram} |
| 1229 |
% [start style=arrow,fill/.style={fill=cyan!20},draw/.style={draw=blue}] |
| 1230 |
% \sankeynode{name=a,quantity=10} |
| 1231 |
% \sankeystart{a} |
| 1232 |
% \sankeynode{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 1233 |
% \sankeystart{b} |
| 1234 |
% \sankeynode{name=c,quantity=20,angle=-90,at={5,1},anchor=right} |
| 1235 |
% \sankeystart{c} |
| 1236 |
% \end{sankeydiagram} |
| 1237 |
% \end{tikzpicture} |
| 1238 |
% \end{VerbatimOut} |
| 1239 |
% % |
| 1240 |
% {\centering\input{\samplecodename}\par} |
| 1241 |
% % |
| 1242 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1243 |
% \end{miniblock} |
| 1244 |
%^^A % ------------------------------------------------------------ |
| 1245 |
% |
| 1246 |
% |
| 1247 |
% \begin{miniblock} |
| 1248 |
% \DescribeMacro{\sankeyend} % |
| 1249 |
% \MACRO\code{\sankeyend}\OPTARG{\VAR{options}}\ARG{\VAR{name}} |
| 1250 |
% |
| 1251 |
% The \code{\sankeyend} fills/draws an ending extremity attached to |
| 1252 |
% the preexisting Sankey node \VAR{name}: |
| 1253 |
% |
| 1254 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1255 |
% \begin{tikzpicture} |
| 1256 |
% \begin{sankeydiagram} |
| 1257 |
% [end style=simple,fill/.style={fill=cyan!20},draw/.style={draw=blue}] |
| 1258 |
% \sankeynode{name=a,quantity=10} |
| 1259 |
% \sankeyend{a} |
| 1260 |
% \sankeynode{name=b,quantity=5,angle=45,at={2,1},anchor=left} |
| 1261 |
% \sankeyend{b} |
| 1262 |
% \sankeynode{name=c,quantity=20,angle=-90,at={5,1},anchor=right} |
| 1263 |
% \sankeyend{c} |
| 1264 |
% \end{sankeydiagram} |
| 1265 |
% \end{tikzpicture} |
| 1266 |
% \end{VerbatimOut} |
| 1267 |
% % |
| 1268 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1269 |
% % |
| 1270 |
% {\centering\input{\samplecodename}\par} |
| 1271 |
% \end{miniblock} |
| 1272 |
% |
| 1273 |
%^^A % ------------------------------------------------------------ |
| 1274 |
% \subsection{Forked node} |
| 1275 |
%^^A % ------------------------------------------------------------ |
| 1276 |
% |
| 1277 |
%^^A % ------------------------------------------------------------ |
| 1278 |
% \subsubsection{Create and fork a Sankey node} |
| 1279 |
%^^A % ------------------------------------------------------------ |
| 1280 |
% |
| 1281 |
% \changes{v3.0}{2021/03/14}{Add keys to fork a Sankey node during its |
| 1282 |
% creation} |
| 1283 |
% |
| 1284 |
% \begin{miniblock} |
| 1285 |
% When creating a new Sankey node, the \code{forked} and % |
| 1286 |
% \code{fork anchor} keys allow to fork the node directly \emph{and} to |
| 1287 |
% anchor it on an anchor of a forked subnode. |
| 1288 |
% |
| 1289 |
% \begin{sankeyoption}[/sankey/node parameters]{forked}{\{\VAR{quantity/name pairs}\}}{}{} |
| 1290 |
% The \VAR{quantity/name pairs} is a comma separated list of |
| 1291 |
% \emph{quantity/name} pairs (one for each subnode, from left to |
| 1292 |
% right). The sum of all quantities \emph{must} be equal to the quantity |
| 1293 |
% of the new node to fork. |
| 1294 |
% \end{sankeyoption} |
| 1295 |
% |
| 1296 |
% \begin{sankeyoption}[/sankey/node parameters]{fork anchor}{\VAR{node.anchor}}{}{} |
| 1297 |
% An anchor belonging to the new node \emph{or} belonging to a subnode |
| 1298 |
% (the anchor name must be prefixed by the name of the |
| 1299 |
% node). \emph{Note:} when a \code{fork anchor} key is supplied, the |
| 1300 |
% \code{anchor} key is ignored (with a \emph{warning} message). |
| 1301 |
% \end{sankeyoption} |
| 1302 |
% |
| 1303 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1304 |
% \begin{tikzpicture} |
| 1305 |
% \begin{sankeydiagram} |
| 1306 |
% \sankeyset{ |
| 1307 |
% start style=arrow,end style=arrow, |
| 1308 |
% fill/.style={fill=yellow!10,line width=0pt,draw=yellow!10} |
| 1309 |
% } |
| 1310 |
% |
| 1311 |
% \sankeynode[debug]{ |
| 1312 |
% name=a,quantity=40,angle=-80, |
| 1313 |
% forked={25/b,10/c,5/d}, |
| 1314 |
% fork anchor=c.right, |
| 1315 |
% } |
| 1316 |
% |
| 1317 |
% \sankeyadvance*{b}{1cm} |
| 1318 |
% \sankeyturn*[minimum radius=2cm]{c}{-30} |
| 1319 |
% \sankeyturn*[minimum radius=2cm]{c}{30} |
| 1320 |
% \sankeyturn*[minimum radius=5mm]{d}{-90} |
| 1321 |
% \sankeyadvance{a}{1.5cm} |
| 1322 |
% \foreach \nodename in {b,c,d}{ \sankeystart{\nodename} } |
| 1323 |
% \sankeyend{a} |
| 1324 |
% \end{sankeydiagram} |
| 1325 |
% \end{tikzpicture} |
| 1326 |
% \end{VerbatimOut} |
| 1327 |
% % |
| 1328 |
% {\centering\input{\samplecodename}\par} |
| 1329 |
% % |
| 1330 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1331 |
% \end{miniblock} |
| 1332 |
% |
| 1333 |
% |
| 1334 |
%^^A % ------------------------------------------------------------ |
| 1335 |
% \subsubsection{Fork a Sankey node} |
| 1336 |
%^^A % ------------------------------------------------------------ |
| 1337 |
% \begin{miniblock} |
| 1338 |
% \DescribeMacro{\sankeyfork} % |
| 1339 |
% \MACRO\code{\sankeyfork}\OPTARG{\VAR{options}}\ARG{\VAR{name}}\ARG{\VAR{quantity/name pairs}} |
| 1340 |
% |
| 1341 |
% The \code{\sankeyfork} macro splits the preexisting Sankey node |
| 1342 |
% named \VAR{name} in a list of new Sankey subnodes. The |
| 1343 |
% \VAR{quantity/name pairs} is a comma separated list of |
| 1344 |
% \emph{quantity/name} pairs, one for each subnode from left to |
| 1345 |
% right. The sum of all quantities \emph{must} be equal to the |
| 1346 |
% quantity of the node to fork. |
| 1347 |
% |
| 1348 |
% \begin{VerbatimOut}[gobble=2]{\samplecodename} |
| 1349 |
% \begin{tikzpicture} |
| 1350 |
% \begin{sankeydiagram} |
| 1351 |
% \sankeynode{name=a,quantity=40,angle=-45} |
| 1352 |
% \sankeyfork[debug]{a}{25/b,10/c,5/d} |
| 1353 |
% \path (a.left) rectangle (a.right); %^^A create a bounding box |
| 1354 |
% \end{sankeydiagram} |
| 1355 |
% \end{tikzpicture} |
| 1356 |
% \end{VerbatimOut} |
| 1357 |
% % |
| 1358 |
% {\centering\input{\samplecodename}\par} |
| 1359 |
% % |
| 1360 |
% \lstinputlisting[style=LaTeXsmall]{\samplecodename} |
| 1361 |
% \end{miniblock} |
| 1362 |
% |
| 1363 |
%^^A % ------------------------------------------------------------ |
| 1364 |
% \section{Miscellaneous} |
| 1365 |
%^^A % ------------------------------------------------------------ |
| 1366 |
% |
| 1367 |
%^^A % ------------------------------------------------------------ |
| 1368 |
% \subsection{The \ttintitle{debug} layer} |
| 1369 |
%^^A % ------------------------------------------------------------ |
| 1370 |
% |
| 1371 |
% The options \code{debug} key uses the \code{sankeydebug} layer to draw |
| 1372 |
% above the \code{main} TikZ layer (via \code{\pgfsetlayers}, the |
| 1373 |
% \code{sankey} package installs four layers: \code{background}, |
| 1374 |
% \code{main}, \code{foreground}, \code{sankeydebug}). |
| 1375 |
% |
| 1376 |
% The four following styles define how to display debug information: |
| 1377 |
% |
| 1378 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 1379 |
% \sankeyset{ |
| 1380 |
% debug color/.style={/utils/exec={\colorlet{debug color}{#1}}}, |
| 1381 |
% % debug color used by all debug macros |
| 1382 |
% debug color=red!75!black, |
| 1383 |
% % debug line between left and right anchors |
| 1384 |
% debug line/.style={overlay,draw=debug color,|-|}, |
| 1385 |
% % debug line between center and label |
| 1386 |
% debug normal/.style={overlay,draw=debug color}, |
| 1387 |
% % debug node label |
| 1388 |
% debug label/.style={ |
| 1389 |
% overlay, |
| 1390 |
% draw, |
| 1391 |
% font=\ttfamily\tiny, |
| 1392 |
% text=debug color,text opacity=1, |
| 1393 |
% inner sep=.1em, |
| 1394 |
% fill=white,fill opacity=1, |
| 1395 |
% rounded corners=.1em, |
| 1396 |
% node contents={\name}, |
| 1397 |
% }, |
| 1398 |
% } |
| 1399 |
% \end{lstlisting} |
| 1400 |
% |
| 1401 |
%^^A % ------------------------------------------------------------ |
| 1402 |
% \subsection{The \ttintitle{dubins} TikZ library} |
| 1403 |
% \label{sec:dubins} |
| 1404 |
%^^A % ------------------------------------------------------------ |
| 1405 |
% |
| 1406 |
% The \code{sankey} package uses the \code{dubins} TikZ library (the |
| 1407 |
% \code{tikzlibrarydubins.code.tex} file) to compute Dubins paths. The |
| 1408 |
% documentation for this library does not yet exist. |
| 1409 |
% |
| 1410 |
%^^A % ------------------------------------------------------------ |
| 1411 |
% \subsection{How to duplicate a Sankey node} |
| 1412 |
%^^A % ------------------------------------------------------------ |
| 1413 |
% |
| 1414 |
% \DescribeMacro{\sankeynodealias} % |
| 1415 |
% \MACRO\code{\sankeynodealias}\ARG{\VAR{origname}}\ARG{\VAR{clonename}} |
| 1416 |
% |
| 1417 |
% The \code{\sankeynodealias} macro clones the Sankey node named |
| 1418 |
% \VAR{origname} into the Sankey node named \VAR{clonename}. |
| 1419 |
% |
| 1420 |
% So, you can clone a Sankey node via two methods: |
| 1421 |
% |
| 1422 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 1423 |
% \sankeynode{name=a,quantity=10} |
| 1424 |
% \sankeynode{as=a,name=b} |
| 1425 |
% \end{lstlisting} |
| 1426 |
% |
| 1427 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 1428 |
% \sankeynode{name=a,quantity=10} |
| 1429 |
% \sankeynodealias{a}{b} |
| 1430 |
% \end{lstlisting} |
| 1431 |
% |
| 1432 |
%^^A % ------------------------------------------------------------ |
| 1433 |
% \subsection{How to define new start and end styles} |
| 1434 |
%^^A % ------------------------------------------------------------ |
| 1435 |
% |
| 1436 |
% Here are the definitions of the \code{arrow} styles: |
| 1437 |
% |
| 1438 |
% \begin{lstlisting}[style=LaTeXsmall] |
| 1439 |
% \sankeyset{ |
| 1440 |
% %% arrow style |
| 1441 |
% new start style={arrow}{ |
| 1442 |
% (\name.left) -- ++(-10pt,0) |
| 1443 |
% -- ([xshift=-10pt/6]\name.center) |
| 1444 |
% -- ([xshift=-10pt]\name.right) |
| 1445 |
% -- (\name.right) -- cycle |
| 1446 |
% }{ |
| 1447 |
% (\name.left) -- ++(-10pt,0) |
| 1448 |
% -- ([xshift=-10pt/6]\name.center) |
| 1449 |
% -- ([xshift=-10pt]\name.right) |
| 1450 |
% -- (\name.right) |
| 1451 |
% }, |
| 1452 |
% new end style={arrow}{ |
| 1453 |
% (\name.left) -- ([yshift=1mm]\name.left) |
| 1454 |
% -- ([xshift=10pt]\name.center) |
| 1455 |
% -- ([yshift=-1mm]\name.right) -- (\name.right) -- cycle |
| 1456 |
% }{ |
| 1457 |
% (\name.left) -- ([yshift=1mm]\name.left) |
| 1458 |
% -- ([xshift=10pt]\name.center) |
| 1459 |
% -- ([yshift=-1mm]\name.right) -- (\name.right) |
| 1460 |
% }, |
| 1461 |
% } |
| 1462 |
% \end{lstlisting} |
| 1463 |
% |
| 1464 |
%^^A % ------------------------------------------------------------ |
| 1465 |
% \section{Todo} |
| 1466 |
%^^A % ------------------------------------------------------------ |
| 1467 |
% |
| 1468 |
% \begin{itemize} |
| 1469 |
% \item Document the \code{dubins} TikZ library. |
| 1470 |
% \item Add a tutorial. |
| 1471 |
% \item Add examples with cycle(s). |
| 1472 |
% \end{itemize} |
| 1473 |
% |
| 1474 |
% ^^A % ------------------------------------------------------------ |
| 1475 |
% \clearpage |
| 1476 |
% |
| 1477 |
% \manualparts |
| 1478 |
% |
| 1479 |
% \part{Examples} |
| 1480 |
% \label{examples} |
| 1481 |
%^^A % ------------------------------------------------------------ |
| 1482 |
% { |
| 1483 |
% \setlength{\parskip}{0pt} |
| 1484 |
% \localtableofcontents |
| 1485 |
% \listoffigures |
| 1486 |
% } |
| 1487 |
% |
| 1488 |
% \tikzset{every picture/.style={}} |
| 1489 |
%^^A % ------------------------------------------------------------ |
| 1490 |
% |
| 1491 |
%^^A % ------------------------------------------------------------ |
| 1492 |
% \clearpage |
| 1493 |
% \section{Simple example} |
| 1494 |
%^^A % ------------------------------------------------------------ |
| 1495 |
% |
| 1496 |
% \embedfile[mimetype=text/plain]{sankey-example1.tex} |
| 1497 |
% |
| 1498 |
% \begin{figure} |
| 1499 |
% \centering |
| 1500 |
% {\MakePercentComment\input{sankey-example1.tex}} |
| 1501 |
% \caption{Simple example} |
| 1502 |
% \label{fig:simple-example} |
| 1503 |
% \end{figure} |
| 1504 |
% |
| 1505 |
% See figure~\vref{fig:simple-example}. The \code{sankey-example1.tex} |
| 1506 |
% file contains the following code and is an attachement of the current |
| 1507 |
% PDF document. |
| 1508 |
% |
| 1509 |
% \lstinputlisting[style=LaTeXsmall]{sankey-example1.tex} |
| 1510 |
% |
| 1511 |
% \iffalse |
| 1512 |
%<*example1> |
| 1513 |
\begin{tikzpicture} |
| 1514 |
\begin{sankeydiagram}%[debug] |
| 1515 |
\colorlet{cold}[rgb]{cyan!75!blue!50!white} |
| 1516 |
\colorlet{hot}[rgb]{red!50!orange!75!white} |
| 1517 |
\sankeyset{ |
| 1518 |
ratio=90pt/6,minimum radius=15pt, |
| 1519 |
start style=simple,end style=simple, |
| 1520 |
draw/.style={ |
| 1521 |
draw=blue!50!cyan, |
| 1522 |
line width=1pt,line cap=round,line join=round, |
| 1523 |
}, |
| 1524 |
cold/.style={ |
| 1525 |
fill/.style={ |
| 1526 |
draw=cold,line width=0pt,fill=cold, |
| 1527 |
}, |
| 1528 |
}, |
| 1529 |
cold to hot/.style={ |
| 1530 |
fill/.style={ |
| 1531 |
fill=none,top color=cold, |
| 1532 |
bottom color=hot,middle color=yellow, |
| 1533 |
}, |
| 1534 |
}, |
| 1535 |
hot/.style={ |
| 1536 |
fill/.style={ |
| 1537 |
draw=hot,line width=0pt,fill=hot, |
| 1538 |
}, |
| 1539 |
}, |
| 1540 |
} |
| 1541 |
|
| 1542 |
\sankeyset{cold} |
| 1543 |
\sankeynodestart{name=p0,at={100,0},angle=-90,quantity=6} |
| 1544 |
\sankeyadvance{p0}{50pt} |
| 1545 |
\sankeyfork{p0}{3/p1,3/p2} |
| 1546 |
\sankeyturnleft{p1}{90} |
| 1547 |
\sankeyadvance{p1}{20pt} |
| 1548 |
\sankeyadvance{p2}{60pt} |
| 1549 |
\sankeyfork{p2}{2/p3,1/p4} |
| 1550 |
\sankeyturnleft{p3}{90} |
| 1551 |
\sankeyadvance{p3}{50pt} |
| 1552 |
\sankeyfork{p3}{1/p5,1/p6} |
| 1553 |
\sankeyadvance{p5}{70pt} |
| 1554 |
\sankeyfork{p1}{1/p7,1/p8,1/p9} |
| 1555 |
\sankeyadvance{p7}{50pt} |
| 1556 |
\sankeyadvance{p9}{50pt} |
| 1557 |
\sankeyadvance{p4}{40pt} |
| 1558 |
\sankeyturnleft{p4}{90} |
| 1559 |
\sankeyadvance{p4}{65pt} |
| 1560 |
\sankeyadvance{p7}{40pt} |
| 1561 |
\sankeynode{ |
| 1562 |
name=p11,at={[shift={(50pt,-15pt)}]p7},quantity=3, |
| 1563 |
forked={1/p7a,1/p9a,1/p5a}, |
| 1564 |
} |
| 1565 |
\sankeyoutin{p7}{p7a} |
| 1566 |
\sankeyoutin{p9}{p9a} |
| 1567 |
\sankeyoutin{p5}{p5a} |
| 1568 |
\sankeyadvance{p11}{30pt} |
| 1569 |
\sankeyend{p11} |
| 1570 |
\sankeyturnright{p8}{90} |
| 1571 |
\sankeyturnright{p6}{90} |
| 1572 |
\sankeyturnright{p4}{90} |
| 1573 |
\sankeyset{hot} |
| 1574 |
\sankeyadvance[cold to hot]{p8}{40pt} |
| 1575 |
\sankeynode{ |
| 1576 |
name=p10,at={[shift={(-15pt,-60pt)}]p8},angle=-90,quantity=3, |
| 1577 |
forked={1/p8a,1/p6a,1/p4a}, |
| 1578 |
} |
| 1579 |
\sankeyoutin[cold to hot]{p4}{p4a} |
| 1580 |
\sankeyoutin[cold to hot]{p6}{p6a} |
| 1581 |
\sankeyoutin{p8}{p8a} |
| 1582 |
\sankeyadvance{p10}{30pt} |
| 1583 |
\sankeyend{p10} |
| 1584 |
\end{sankeydiagram} |
| 1585 |
\end{tikzpicture} |
| 1586 |
%</example1> |
| 1587 |
% \fi |
| 1588 |
% |
| 1589 |
%^^A % ------------------------------------------------------------ |
| 1590 |
% \clearpage |
| 1591 |
% \section{Energy diagram} |
| 1592 |
%^^A % ------------------------------------------------------------ |
| 1593 |
% |
| 1594 |
% \embedfile[mimetype=text/plain]{sankey-example-energy.tex} |
| 1595 |
% |
| 1596 |
% \begin{figure} |
| 1597 |
% \centering |
| 1598 |
% {\MakePercentComment\input{sankey-example-energy.tex}} |
| 1599 |
% \caption{Energy diagram} |
| 1600 |
% \label{fig:very-simple-example} |
| 1601 |
% \end{figure} |
| 1602 |
% |
| 1603 |
% This example comes from |
| 1604 |
% \href{https://ibphysicsblog.wordpress.com/2015/10/23/sankey-diagrams/}{IB |
| 1605 |
% Pysics Blog} by Kyu Won Shim. |
| 1606 |
% |
| 1607 |
% See figure~\vref{fig:very-simple-example}. The \code{sankey-example-energy.tex} |
| 1608 |
% file contains the following code and is an attachement of the current |
| 1609 |
% PDF document. |
| 1610 |
% |
| 1611 |
% \lstinputlisting[style=LaTeXsmall]{sankey-example-energy.tex} |
| 1612 |
% |
| 1613 |
% \iffalse |
| 1614 |
%<*example-energy> |
| 1615 |
\begin{tikzpicture} |
| 1616 |
% font choice |
| 1617 |
\renewcommand\rmdefault{txr}\rmfamily\footnotesize |
| 1618 |
\sisetup{ |
| 1619 |
round-mode=places, |
| 1620 |
round-precision=1, |
| 1621 |
add-decimal-zero, |
| 1622 |
round-pad=true, |
| 1623 |
} |
| 1624 |
\begin{sankeydiagram} |
| 1625 |
\colorlet{energy}{blue!30!cyan!80!black} |
| 1626 |
\colorlet{lost energy}{red!50!orange!90!black} |
| 1627 |
\sankeyset{ |
| 1628 |
ratio=13em/100, |
| 1629 |
minimum radius=1em, |
| 1630 |
start style=simple,end style=simple, |
| 1631 |
draw/.style={draw=none,line width=0}, |
| 1632 |
energy/.style={ |
| 1633 |
fill/.style={ |
| 1634 |
draw=energy, |
| 1635 |
line width=0, |
| 1636 |
fill=energy, |
| 1637 |
} |
| 1638 |
}, |
| 1639 |
lost energy/.style={ |
| 1640 |
fill/.style={ |
| 1641 |
draw=lost energy, |
| 1642 |
line width=0, |
| 1643 |
fill=lost energy, |
| 1644 |
} |
| 1645 |
} |
| 1646 |
} |
| 1647 |
|
| 1648 |
\newcommand\abovelabel[2]{ % valname, label |
| 1649 |
\node[anchor=south east,align=center,inner xsep=0] at (#1.left) {#2}; |
| 1650 |
} |
| 1651 |
|
| 1652 |
\newcommand\energylabel[1]{ % valname |
| 1653 |
\node[anchor=north east,text=energy,inner xsep=0] at (#1.right) |
| 1654 |
{\num{\sankeygetnodeqty{#1}}}; |
| 1655 |
} |
| 1656 |
|
| 1657 |
\newcommand\lostenergylabel[2]{ % valname, label |
| 1658 |
\node[anchor=north,text=lost energy] at ([yshift=-2.5mm]#1.center) |
| 1659 |
(value) |
| 1660 |
{\num{\sankeygetnodeqty{#1}}}; |
| 1661 |
\node[anchor=north,inner sep=0,align=center] at (value.south) {#2}; |
| 1662 |
} |
| 1663 |
|
| 1664 |
\newcommand\lostenergylabelbottom[2]{ % valname, label |
| 1665 |
\draw[draw=lost energy,dashed,thick] |
| 1666 |
([yshift=-3mm]#1.center) coordinate (#1) -- ([yshift=-3mm]#1.center); |
| 1667 |
\lostenergylabel{#1}{#2} |
| 1668 |
} |
| 1669 |
|
| 1670 |
\sankeynode{name=Co,quantity=100.0} |
| 1671 |
\path (Co.right) ++(0,-7mm) coordinate (c); |
| 1672 |
|
| 1673 |
\newcommand\turnandstop[2]{ % valname, label |
| 1674 |
\begingroup |
| 1675 |
\sankeyset{lost energy} |
| 1676 |
\sankeyturnright{#1}{90} |
| 1677 |
\sankeynode{as=#1,name=#1-stop,at={#1 |- c}} |
| 1678 |
\sankeyoutin{#1}{#1-stop} |
| 1679 |
\sankeynode{as=#1-stop,name=#1} |
| 1680 |
\sankeyend{#1} |
| 1681 |
\lostenergylabel{#1}{#2} |
| 1682 |
\endgroup |
| 1683 |
} |
| 1684 |
|
| 1685 |
\newcommand\turnandstopbottom[2]{ % valname, label |
| 1686 |
\begingroup |
| 1687 |
\sankeyset{lost energy} |
| 1688 |
\sankeyturnright{#1}{90} |
| 1689 |
\sankeynode{as=#1,name=#1-stop,at={#1 |- c}} |
| 1690 |
\sankeyoutin{#1}{#1-stop} |
| 1691 |
\sankeynode{as=#1-stop,name=#1} |
| 1692 |
\sankeyend{#1} |
| 1693 |
\lostenergylabelbottom{#1}{#2} |
| 1694 |
\endgroup |
| 1695 |
} |
| 1696 |
|
| 1697 |
\def\hshift{6.25em} |
| 1698 |
|
| 1699 |
\sankeyadvance[energy]{Co}{1.2*\hshift} |
| 1700 |
\abovelabel{Co}{\textbf{Coal}\\(Primary energy)} |
| 1701 |
\energylabel{Co} |
| 1702 |
\sankeyfork{Co}{35/El1,65/Pg} |
| 1703 |
\turnandstop{Pg}{Power generation} |
| 1704 |
|
| 1705 |
\sankeyadvance[energy]{El1}{1.8*\hshift} |
| 1706 |
\abovelabel{El1}{\textbf{Electricity}\\(Secondary energy)} |
| 1707 |
\energylabel{El1} |
| 1708 |
\sankeyfork{El1}{33.5/El2,1.5/Tr} |
| 1709 |
\turnandstopbottom{Tr}{Transmission} |
| 1710 |
|
| 1711 |
\sankeyadvance[energy]{El2}{.65*\hshift} |
| 1712 |
\energylabel{El2} |
| 1713 |
\sankeyfork{El2}{31.5/El3,2.0/Di} |
| 1714 |
\turnandstop{Di}{Distribution} |
| 1715 |
|
| 1716 |
\sankeyadvance[energy]{El3}{.65*\hshift} |
| 1717 |
\energylabel{El3} |
| 1718 |
\sankeyfork{El3}{31.0/El4,0.5/Wi} |
| 1719 |
\turnandstopbottom{Wi}{Wiring} |
| 1720 |
|
| 1721 |
\sankeyadvance[energy]{El4}{.65*\hshift} |
| 1722 |
\abovelabel{El4}{\textbf{Electricity}\\(Final energy)} |
| 1723 |
\energylabel{El4} |
| 1724 |
\sankeyfork{El4}{3.0/Lr1,28.0/Lb} |
| 1725 |
\turnandstop{Lb}{Lightbulb} |
| 1726 |
|
| 1727 |
\sankeyadvance[energy]{Lr1}{1.1*\hshift} |
| 1728 |
\abovelabel{Lr1}{\textbf{Light radiation}\\(Useful energy)} |
| 1729 |
\energylabel{Lr1} |
| 1730 |
\sankeyfork{Lr1}{2.0/Lr2,1.0/Ls} |
| 1731 |
\turnandstopbottom{Ls}{Lampshade} |
| 1732 |
|
| 1733 |
\sankeyadvance[energy]{Lr2}{.6*\hshift} |
| 1734 |
\energylabel{Lr2} |
| 1735 |
\sankeyfork{Lr2}{1.0/Il,1.0/Id} |
| 1736 |
\turnandstop{Id}{Idle} |
| 1737 |
|
| 1738 |
\sankeyadvance[energy]{Il}{.6*\hshift} |
| 1739 |
\abovelabel{Il}{\textbf{Illumination}\\(Energy services)} |
| 1740 |
\energylabel{Il} |
| 1741 |
\sankeyend[energy]{Il} |
| 1742 |
\end{sankeydiagram} |
| 1743 |
\end{tikzpicture} |
| 1744 |
%</example-energy> |
| 1745 |
% \fi |
| 1746 |
%^^A % ------------------------------------------------------------ |
| 1747 |
% \clearpage |
| 1748 |
% \section{Example from question on TeX.se} |
| 1749 |
%^^A % ------------------------------------------------------------ |
| 1750 |
% |
| 1751 |
% \changes{v3.0}{2021/03/14}{Fix bad names in second example} |
| 1752 |
% |
| 1753 |
% \embedfile[mimetype=text/plain]{sankey-example2.tex} |
| 1754 |
% |
| 1755 |
% \begin{figure} |
| 1756 |
% \centering |
| 1757 |
% {\MakePercentComment\input{sankey-example2}} |
| 1758 |
% \caption{Example from TeX.se question} |
| 1759 |
% \label{fig:texse-example} |
| 1760 |
% \end{figure} |
| 1761 |
% |
| 1762 |
% This example came from |
| 1763 |
% \href{https://tex.stackexchange.com/q/40159/14500}{this question} on |
| 1764 |
% \href{https://tex.stackexchange.com/}{TeX.StackExchange}. |
| 1765 |
% |
| 1766 |
% See figure~\vref{fig:texse-example}. The \code{sankey-example2.tex} |
| 1767 |
% file contains the following code and is an attachement of the current |
| 1768 |
% PDF document. |
| 1769 |
% |
| 1770 |
% \lstinputlisting[style=LaTeXsmall]{sankey-example2} |
| 1771 |
% |
| 1772 |
% \iffalse |
| 1773 |
%<*example2> |
| 1774 |
\begin{tikzpicture} |
| 1775 |
\renewcommand*\sfdefault{txss} |
| 1776 |
|
| 1777 |
\begin{sankeydiagram}%[debug] |
| 1778 |
\sankeyset{ |
| 1779 |
ratio=4cm/524.3, |
| 1780 |
minimum radius=3mm, |
| 1781 |
start style=arrow, |
| 1782 |
end style=arrow, |
| 1783 |
fill/.style={ |
| 1784 |
line width=0pt, |
| 1785 |
fill=cyan!50!blue!50!black, |
| 1786 |
draw=cyan!50!blue!50!black, |
| 1787 |
}, |
| 1788 |
draw/.style={draw=none}, |
| 1789 |
every node/.style={angle=-90}, |
| 1790 |
} |
| 1791 |
|
| 1792 |
\sankeynodestart{name=B,at={-.5,0},quantity=7.2} |
| 1793 |
\coordinate[below=1mm of B.center] (B label); |
| 1794 |
\sankeyadvance{B}{5mm} |
| 1795 |
\sankeynodestart{name=GI,at={1,0},quantity=137.3} |
| 1796 |
\coordinate[below=1mm of GI.center] (GI label); |
| 1797 |
\sankeyadvance{GI}{5mm} |
| 1798 |
\sankeynodestart{name=I,at={4,0},quantity=397.8} |
| 1799 |
\coordinate[below=1mm of I.center] (I label); |
| 1800 |
\sankeynode{ |
| 1801 |
name=EI,at={2.86,-3},quantity=542.3, |
| 1802 |
forked={397.8/Ia,137.3/GIa,7.2/Ba} |
| 1803 |
} |
| 1804 |
\sankeydubins[minimum radius=1.2cm]{I}{Ia} |
| 1805 |
\sankeyoutin{GI}{GIa} |
| 1806 |
\sankeyoutin{B}{Ba} |
| 1807 |
\sankeyadvance{EI}{5mm} |
| 1808 |
\coordinate (EI label) at (EI); |
| 1809 |
\sankeyadvance{EI}{5mm} |
| 1810 |
\sankeyfork{EI}{63.1/EB,479.2/P} |
| 1811 |
|
| 1812 |
\sankeyturnleft{EB}{90} |
| 1813 |
\sankeyadvance{EB}{4cm} |
| 1814 |
\coordinate (EB label) at ($(EB)!.5!(EB-old)$); |
| 1815 |
\sankeyend{EB} |
| 1816 |
|
| 1817 |
\sankeyadvance{P}{10mm} |
| 1818 |
\coordinate (P label) at (P); |
| 1819 |
\sankeyadvance{P}{5mm} |
| 1820 |
|
| 1821 |
\sankeyfork{P}{33.5/NV,445.7/P-NV} |
| 1822 |
|
| 1823 |
{ |
| 1824 |
\colorlet{NV color}{cyan!80!lime!50!gray} |
| 1825 |
\sankeyset{fill/.append style={fill=NV color,draw=NV color}} |
| 1826 |
\sankeyturnleft{NV}{90} |
| 1827 |
\sankeynode{as=NV,name=NV2,at=NV -| EB} |
| 1828 |
\sankeyoutin{NV}{NV2} |
| 1829 |
\coordinate (NV label) at (NV -| EB label); |
| 1830 |
\sankeyend{NV2} |
| 1831 |
} |
| 1832 |
|
| 1833 |
\sankeyadvance{P-NV}{10mm} |
| 1834 |
\sankeyfork{P-NV}{118.1/U,327.6/P-NV-U} |
| 1835 |
|
| 1836 |
{ |
| 1837 |
\sankeyset{ |
| 1838 |
fill/.style={fill=orange!70!gray!50,draw=orange!70!gray!50} |
| 1839 |
} |
| 1840 |
\sankeyturnleft{U}{90} |
| 1841 |
\sankeynode{as=U,name=U2,at=U -| EB} |
| 1842 |
\sankeyoutin{U}{U2} |
| 1843 |
\coordinate (U label) at (U -| EB label); |
| 1844 |
\sankeyend{U2} |
| 1845 |
} |
| 1846 |
|
| 1847 |
\sankeyadvance{P-NV-U}{10mm} |
| 1848 |
\sankeyfork{P-NV-U}{327.2/P-NV-U-SD,0.4/SD} |
| 1849 |
|
| 1850 |
{ |
| 1851 |
\sankeyturnright{SD}{90} |
| 1852 |
\sankeyadvance{SD}{15mm} |
| 1853 |
\coordinate (SD label) at (SD); |
| 1854 |
\sankeyadvance{SD}{15mm} |
| 1855 |
\sankeyend{SD} |
| 1856 |
} |
| 1857 |
|
| 1858 |
\sankeyadvance{P-NV-U-SD}{8mm} |
| 1859 |
\sankeyfork{P-NV-U-SD}{18.8/VE,308.4/E} |
| 1860 |
|
| 1861 |
{ |
| 1862 |
\sankeyset{fill/.append style={orange!70!gray!30}} |
| 1863 |
\sankeyturnleft{VE}{90} |
| 1864 |
\sankeynode{as=VE,name=VE2,at=VE -| EB} |
| 1865 |
\sankeyoutin{VE}{VE2} |
| 1866 |
\coordinate (VE label) at (VE -| EB label); |
| 1867 |
\sankeyend{VE2} |
| 1868 |
} |
| 1869 |
|
| 1870 |
\sankeyadvance{E}{8mm} |
| 1871 |
\coordinate (E label) at (E); |
| 1872 |
\sankeyadvance{E}{20mm} |
| 1873 |
\sankeyfork{E}{135.1/H+GHD,87.2/V,86.1/In} |
| 1874 |
|
| 1875 |
\sankeyturnright{In}{90} |
| 1876 |
\sankeyadvance{In}{10mm} |
| 1877 |
\sankeyturnleft{In}{90} |
| 1878 |
\sankeyadvance{In}{5mm} |
| 1879 |
\coordinate (In label) at (In); |
| 1880 |
\sankeyadvance{In}{10mm} |
| 1881 |
\sankeyend{In} |
| 1882 |
|
| 1883 |
\sankeynode{as=V,name=V2,at=V|-In label} |
| 1884 |
\sankeyoutin{V}{V2} |
| 1885 |
\coordinate (V label) at (V2); |
| 1886 |
\sankeyadvance{V2}{10mm} |
| 1887 |
\sankeyend{V2} |
| 1888 |
|
| 1889 |
\sankeyturnleft{H+GHD}{90} |
| 1890 |
\sankeyadvance{H+GHD}{5mm} |
| 1891 |
\sankeyfork{H+GHD}{47.0/GHD,88.1/H} |
| 1892 |
|
| 1893 |
\sankeyturnright{H}{90} |
| 1894 |
\sankeynode{as=H,name=H2,at=H|-In label} |
| 1895 |
\sankeyoutin{H}{H2} |
| 1896 |
\coordinate (H label) at (H2); |
| 1897 |
\sankeyadvance{H2}{10mm} |
| 1898 |
\sankeyend{H2} |
| 1899 |
|
| 1900 |
\sankeyadvance{GHD}{30mm} |
| 1901 |
\sankeyturnright{GHD}{90} |
| 1902 |
\sankeynode{as=GHD,name=GHD2,at=GHD|-In label} |
| 1903 |
\sankeyoutin{GHD}{GHD2} |
| 1904 |
\coordinate (GHD label) at (GHD2); |
| 1905 |
\sankeyadvance{GHD2}{10mm} |
| 1906 |
\sankeyend{GHD2} |
| 1907 |
\end{sankeydiagram} |
| 1908 |
|
| 1909 |
% labels |
| 1910 |
\tikzset{ |
| 1911 |
label/.style={ |
| 1912 |
fill=white,fill opacity=.8,text opacity=1, |
| 1913 |
inner sep=1mm, |
| 1914 |
text=cyan!50!blue!50!black, |
| 1915 |
inner xsep=2mm, |
| 1916 |
font=\sffamily\bfseries\footnotesize, |
| 1917 |
align=center, |
| 1918 |
}, |
| 1919 |
} |
| 1920 |
\node[label,anchor=north] (B label) at (B label) {7.2}; |
| 1921 |
\node[label,left=1mm of B label] {Bestands-\\entnahme}; |
| 1922 |
\node[label,anchor=north] at (GI label) {137.3}; |
| 1923 |
\node[label,above=5mm of GI label] {Gewinnung\\im Inland}; |
| 1924 |
\node[label,anchor=north] at (I label) {397.8}; |
| 1925 |
\node[label,above=5mm of I label] {Import}; |
| 1926 |
|
| 1927 |
\node[label] at (EI label) {542.3\\Energieaufkommen im Inland}; |
| 1928 |
|
| 1929 |
\node[label,anchor=center] (EB label) at (EB label) {63.1}; |
| 1930 |
\node[label,above=1mm of EB label] {Export und\\Bunkerung}; |
| 1931 |
|
| 1932 |
\node[label] at (P label) {479.2\\Primärenergieverbrauch}; |
| 1933 |
|
| 1934 |
\node[label,anchor=center] (NV label) at (NV label) {33.5}; |
| 1935 |
\node[label,above=0mm of NV label] {Nichtenergetischer Verbrauch}; |
| 1936 |
|
| 1937 |
\node[label,anchor=center] (U label) at (U label) {118.1}; |
| 1938 |
\node[label,below=3mm of U label] {Umwandlungsverluste}; |
| 1939 |
|
| 1940 |
\node[label,anchor=center] (SD label) at (SD label) {0.4}; |
| 1941 |
\node[label,above=0mm of SD label] {Statistische\\Differenzen}; |
| 1942 |
|
| 1943 |
\node[label,anchor=center] (VE label) at (VE label) {18.8}; |
| 1944 |
\node[label,below=0mm of VE label] {Verbrauch in den\\Energiesktoren}; |
| 1945 |
|
| 1946 |
\node[label,anchor=north] (E label) at (E label) |
| 1947 |
{308.4\\Endenergieverbrauch}; |
| 1948 |
|
| 1949 |
\node[label,anchor=north] (In label) at (In label) {86.1}; |
| 1950 |
\node[label,anchor=north,below=1cm of In label] {Industrie}; |
| 1951 |
|
| 1952 |
\node[label,anchor=north] (V label) at (V label) {87.2}; |
| 1953 |
\node[label,anchor=north,below=1cm of V label] {Verkehr}; |
| 1954 |
|
| 1955 |
\node[label,anchor=north] (H label) at (H label) {88.1}; |
| 1956 |
\node[label,anchor=north,below=1cm of H label] {Haushalte}; |
| 1957 |
|
| 1958 |
\node[label,anchor=north] (GHD label) at (GHD label) {47.0}; |
| 1959 |
\node[label,anchor=north,below=1cm of GHD label] |
| 1960 |
{Gewerbe, Handel\\Diensleistungen}; |
| 1961 |
\end{tikzpicture} |
| 1962 |
%</example2> |
| 1963 |
% \fi |
| 1964 |
% |
| 1965 |
%^^A % ------------------------------------------------------------ |
| 1966 |
% \clearpage |
| 1967 |
% \section{Reproduction of an example from Google Charts documentation} |
| 1968 |
%^^A % ------------------------------------------------------------ |
| 1969 |
% |
| 1970 |
% \changes{v3.0}{2021/03/14}{Add the reproduction of an example from |
| 1971 |
% Google Charts documentation} |
| 1972 |
% |
| 1973 |
% \embedfile[mimetype=text/plain]{sankey-example3.tex} |
| 1974 |
% |
| 1975 |
% This example is a reproduction of an example of Google |
| 1976 |
% Charts Documentation\footnote{\url{https://developers.google.com/chart/interactive/docs/gallery/sankey}}. |
| 1977 |
% |
| 1978 |
% See figure \vref{fig:google-example}. The \code{sankey-example3.tex} |
| 1979 |
% file contains the following code and is an attachement of the current |
| 1980 |
% PDF document. |
| 1981 |
% |
| 1982 |
% \begin{figure} |
| 1983 |
% \centering |
| 1984 |
% {\MakePercentComment\input{sankey-example3}} |
| 1985 |
% \caption{Reproduction of an example from Google Charts |
| 1986 |
% documentation} |
| 1987 |
% \label{fig:google-example} |
| 1988 |
% \end{figure} |
| 1989 |
% |
| 1990 |
% \lstinputlisting[style=LaTeXsmall]{sankey-example3} |
| 1991 |
% |
| 1992 |
% \iffalse |
| 1993 |
%<*example3> |
| 1994 |
\begin{tikzpicture} |
| 1995 |
\begin{sankeydiagram}%[debug] |
| 1996 |
\sffamily |
| 1997 |
\sankeyset{ |
| 1998 |
ratio=1cm/10, |
| 1999 |
outin steps=2, |
| 2000 |
draw/.style={draw=none,line width=0pt}, |
| 2001 |
color/.style={fill/.style={fill=#1,fill opacity=.75}}, |
| 2002 |
shade/.style 2 args={fill/.style={left color=#1, |
| 2003 |
right color=#2,fill opacity=.5}}, |
| 2004 |
% colors |
| 2005 |
@define HTML color/.code args={#1/#2}{\definecolor{#1}{HTML}{#2}}, |
| 2006 |
@define HTML color/.list={ |
| 2007 |
cyan/a6cee3,lime/b2df8a,red/fb9a99,orange/fdbf6f, |
| 2008 |
violet/cab2d6,yellow/ffff99,blue/1f78b4,green/33a02c |
| 2009 |
}, |
| 2010 |
% colors of countries |
| 2011 |
@let country color/.code args={#1/#2}{\colorlet{#1}[rgb]{#2}}, |
| 2012 |
@let country color/.list={ |
| 2013 |
CA/red,US/orange,MX/orange,BR/cyan,FR/lime,GB/red, |
| 2014 |
SP/lime,PT/cyan,ML/blue,SN/violet,MA/yellow, |
| 2015 |
AO/violet,ZA/yellow,IN/green,JP/green,CN/blue |
| 2016 |
}, |
| 2017 |
} |
| 2018 |
\def\vdist{5mm} |
| 2019 |
\def\hwidth{.5em} |
| 2020 |
\def\hdist{4.1cm} |
| 2021 |
|
| 2022 |
\sankeynode{name=CA,quantity=7} |
| 2023 |
\sankeynode{name=US,quantity=8,at={[yshift=\vdist]CA.left},anchor=right} |
| 2024 |
\sankeynode{name=MX,quantity=8,at={[yshift=\vdist]US.left},anchor=right} |
| 2025 |
\sankeynode{name=BR,quantity=8,at={[yshift=\vdist]MX.left},anchor=right} |
| 2026 |
|
| 2027 |
\foreach \country in {CA,US,MX,BR}{ |
| 2028 |
\sankeyadvance[color=\country]{\country}{\hwidth} |
| 2029 |
} |
| 2030 |
|
| 2031 |
\sankeyfork{CA}{1/CA-to-PT,1/CA-to-GB,5/CA-to-FR} |
| 2032 |
\sankeyfork{US}{1/US-to-PT,1/US-to-SP,5/US-to-GB,1/US-to-FR} |
| 2033 |
\sankeyfork{MX}{1/MX-to-PT,5/MX-to-SP,1/MX-to-GB,1/MX-to-FR} |
| 2034 |
\sankeyfork{BR}{5/BR-to-PT,1/BR-to-SP,1/BR-to-GB,1/BR-to-FR} |
| 2035 |
|
| 2036 |
\sankeynode{name=FR,quantity=11, |
| 2037 |
at={[xshift=\hdist]CA.right},anchor=right} |
| 2038 |
\sankeynode{name=GB,quantity=11, |
| 2039 |
at={[yshift=\vdist]FR.left},anchor=right} |
| 2040 |
\sankeynode{name=SP,quantity=7, |
| 2041 |
at={[yshift=\vdist]GB.left},anchor=right} |
| 2042 |
\sankeynode{name=PT,quantity=8, |
| 2043 |
at={[yshift=\vdist]SP.left},anchor=right} |
| 2044 |
|
| 2045 |
\sankeyfork{FR} |
| 2046 |
{1/FR-from-BR,1/FR-from-MX,1/FR-from-US,5/FR-from-CA,3/FR-from-00} |
| 2047 |
\sankeyfork{GB} |
| 2048 |
{1/GB-from-BR,1/GB-from-MX,5/GB-from-US,1/GB-from-CA,3/GB-from-00} |
| 2049 |
\sankeyfork{SP}{1/SP-from-BR,5/SP-from-MX,1/SP-from-US} |
| 2050 |
\sankeyfork{PT}{5/PT-from-BR,1/PT-from-MX,1/PT-from-US,1/PT-from-CA} |
| 2051 |
|
| 2052 |
\foreach \country in {FR,GB,SP,PT}{ |
| 2053 |
\sankeyadvance[color=\country]{\country}{\hwidth} |
| 2054 |
} |
| 2055 |
|
| 2056 |
\sankeyfork{FR}{1/FR-to-ZA,1/FR-to-AO,3/FR-to-MA,3/FR-to-SN,3/FR-to-ML} |
| 2057 |
\sankeyfork{GB}{7/GB-to-ZA,1/GB-to-AO,2/GB-to-MA,1/GB-to-SN} |
| 2058 |
\sankeyfork{SP}{1/SP-to-ZA,3/SP-to-MA,1/SP-to-SN,2/SP-to-00} |
| 2059 |
\sankeyfork{PT}{3/PT-to-ZA,2/PT-to-AO,1/PT-to-MA,1/PT-to-SN,1/PT-to-00} |
| 2060 |
|
| 2061 |
\sankeynode{name=ML,quantity=9, |
| 2062 |
at={[xshift=\hdist]FR.right},anchor=right} |
| 2063 |
\sankeynode{name=SN,quantity=9, |
| 2064 |
at={[yshift=\vdist]ML.left},anchor=right} |
| 2065 |
\sankeynode{name=MA,quantity=9, |
| 2066 |
at={[yshift=\vdist]SN.left},anchor=right} |
| 2067 |
\sankeynode{name=AO,quantity=9, |
| 2068 |
at={[yshift=\vdist]MA.left},anchor=right} |
| 2069 |
\sankeynode{name=ZA,quantity=12, |
| 2070 |
at={[yshift=\vdist]AO.left},anchor=right} |
| 2071 |
|
| 2072 |
\sankeyfork{ML}{3/ML-from-FR,6/Mail-from-00} |
| 2073 |
\sankeyfork{SN} |
| 2074 |
{1/SN-from-PT,1/SN-from-SP,1/SN-from-GB,3/SN-from-FR,3/SN-from-00} |
| 2075 |
\sankeyfork{MA}{1/MA-from-PT,3/MA-from-SP,2/MA-from-GB,3/MA-from-FR} |
| 2076 |
\sankeyfork{AO}{2/AO-from-PT,1/AO-from-GB,1/AO-from-FR,5/AO-from-00} |
| 2077 |
\sankeyfork{ZA}{3/ZA-from-PT,1/ZA-from-SP,7/ZA-from-GB,1/ZA-from-FR} |
| 2078 |
|
| 2079 |
\foreach \country in {ML,SN,MA,AO,ZA}{ |
| 2080 |
\sankeyadvance[color=\country]{\country}{\hwidth} |
| 2081 |
} |
| 2082 |
|
| 2083 |
\sankeyfork{ML}{5/ML-to-CN,3/ML-to-JP,1/ML-to-IN} |
| 2084 |
\sankeyfork{SN}{5/SN-to-CN,3/SN-to-JP,1/SN-to-IN} |
| 2085 |
\sankeyfork{MA}{5/MA-to-CN,3/MA-to-JP,1/MA-to-IN} |
| 2086 |
\sankeyfork{AO}{5/AO-to-CN,3/AO-to-JP,1/AO-to-IN} |
| 2087 |
\sankeyfork{ZA}{5/ZA-to-CN,3/ZA-to-JP,1/ZA-to-IN,3/ZA-to-00} |
| 2088 |
|
| 2089 |
\sankeynode{name=IN,quantity=5, |
| 2090 |
at={[xshift=\hdist]ML.right},anchor=right} |
| 2091 |
\sankeynode{name=JP,quantity=15, |
| 2092 |
at={[yshift=\vdist]IN.left},anchor=right} |
| 2093 |
\sankeynode{name=CN,quantity=25, |
| 2094 |
at={[yshift=\vdist]JP.left},anchor=right} |
| 2095 |
|
| 2096 |
\sankeyfork{IN} |
| 2097 |
{1/IN-from-ZA,1/IN-from-AO,1/IN-from-MA,1/IN-from-SN,1/IN-from-ML} |
| 2098 |
\sankeyfork{JP} |
| 2099 |
{3/JP-from-ZA,3/JP-from-AO,3/JP-from-MA,3/JP-from-SN,3/JP-from-ML} |
| 2100 |
\sankeyfork{CN} |
| 2101 |
{5/CN-from-ZA,5/CN-from-AO,5/CN-from-MA,5/CN-from-SN,5/CN-from-ML} |
| 2102 |
|
| 2103 |
\foreach \country in {IN,JP,CN}{ |
| 2104 |
\sankeyadvance[color=\country]{\country}{\hwidth} |
| 2105 |
} |
| 2106 |
|
| 2107 |
\foreach \startcountry/\countries in { |
| 2108 |
CA/{PT,GB,FR}, US/{PT,SP,GB,FR}, MX/{PT,SP,GB,FR}, |
| 2109 |
BR/{PT,SP,GB,FR}, FR/{ML,SN,MA,AO,ZA}, GB/{SN,MA,AO,ZA}, |
| 2110 |
SP/{SN,MA,ZA}, PT/{SN,MA,AO,ZA}, ML/{IN,JP,CN}, |
| 2111 |
SN/{IN,JP,CN}, MA/{IN,JP,CN}, AO/{IN,JP,CN}, |
| 2112 |
ZA/{IN,JP,CN}} |
| 2113 |
{ |
| 2114 |
\foreach \endcountry in \countries { |
| 2115 |
\sankeyoutin[shade={\startcountry}{\endcountry}] |
| 2116 |
{\startcountry-to-\endcountry}{\endcountry-from-\startcountry} |
| 2117 |
} |
| 2118 |
} |
| 2119 |
|
| 2120 |
\foreach \country/\countryname in {CA/Canada, US/USA, MX/Mexico, |
| 2121 |
BR/Brazil, FR/France, GB/England, SP/Spain, PT/Portugal} |
| 2122 |
{ |
| 2123 |
\node[anchor=west,inner sep=.1em,font=\small] |
| 2124 |
at (\country) {\countryname\vphantom{Ag}}; |
| 2125 |
} |
| 2126 |
|
| 2127 |
\foreach \country/\countryname in { |
| 2128 |
ML/Mali, SN/Senegal, MA/Morocco, AO/Angola, |
| 2129 |
ZA/South Africa, IN/India, JP/Japan, CN/China} |
| 2130 |
{ |
| 2131 |
\node[anchor=east,inner sep=.1em,font=\small] |
| 2132 |
at (\country-old) {\countryname\vphantom{Ag}}; |
| 2133 |
} |
| 2134 |
\end{sankeydiagram} |
| 2135 |
\end{tikzpicture} |
| 2136 |
%</example3> |
| 2137 |
% \fi |
| 2138 |
% |
| 2139 |
%^^A % ------------------------------------------------------------ |
| 2140 |
% \subsection{Variation} |
| 2141 |
%^^A % ------------------------------------------------------------ |
| 2142 |
% |
| 2143 |
% Here is a variation of the previous example using the \code{rotate} |
| 2144 |
% key. |
| 2145 |
% |
| 2146 |
% See figure \vref{fig:google-example-variation}. The |
| 2147 |
% \code{sankey-example3-variation.tex} file contains the following code |
| 2148 |
% and is an attachement of the current PDF document. |
| 2149 |
% |
| 2150 |
% \begin{figure} |
| 2151 |
% \centering |
| 2152 |
% {\MakePercentComment\input{sankey-example3-variation}} |
| 2153 |
% \caption{Reproduction of an example from Google Charts documentation |
| 2154 |
% -- variation using the \protect\texttt{rotate} key.} |
| 2155 |
% \label{fig:google-example-variation} |
| 2156 |
% \end{figure} |
| 2157 |
% |
| 2158 |
% \lstinputlisting[style=LaTeXsmall]{sankey-example3-variation} |
| 2159 |
% |
| 2160 |
% \iffalse |
| 2161 |
%<*example3-variation> |
| 2162 |
\begin{tikzpicture}[rotate=-90] |
| 2163 |
\begin{sankeydiagram}[rotate=-90] |
| 2164 |
\sffamily |
| 2165 |
\sankeyset{ |
| 2166 |
ratio=1.7cm/10, |
| 2167 |
outin steps=2, |
| 2168 |
start style=arrow, |
| 2169 |
end style=simple, |
| 2170 |
draw/.style={draw=white,line width=.4pt}, |
| 2171 |
color/.style={fill/.style={fill=#1,fill opacity=.75}}, |
| 2172 |
shade/.style 2 args={fill/.style={ |
| 2173 |
fill=none,line width=0, |
| 2174 |
top color=#1,bottom color=#2, |
| 2175 |
middle color=#1!50!#2!50!white, |
| 2176 |
fill opacity=.75}}, |
| 2177 |
% colors |
| 2178 |
@define HTML color/.code args={#1/#2}{\definecolor{#1}{HTML}{#2}}, |
| 2179 |
@define HTML color/.list={ |
| 2180 |
cyan/a6cee3,lime/b2df8a,red/fb9a99,orange/fdbf6f, |
| 2181 |
violet/cab2d6,yellow/ffff99,blue/1f78b4,green/33a02c |
| 2182 |
}, |
| 2183 |
% colors of countries |
| 2184 |
@let country color/.code args={#1/#2}{\colorlet{#1}[rgb]{#2}}, |
| 2185 |
@let country color/.list={ |
| 2186 |
CA/red,US/orange,MX/lime,BR/violet,FR/yellow,GB/blue, |
| 2187 |
SP/green,PT/cyan,ML/cyan,SN/red,MA/orange, |
| 2188 |
AO/violet,ZA/lime,IN/blue,JP/yellow,CN/green |
| 2189 |
}, |
| 2190 |
} |
| 2191 |
\def\vdist{5mm} |
| 2192 |
\def\hwidth{1em} |
| 2193 |
\def\hdist{6cm} |
| 2194 |
|
| 2195 |
\sankeynode{name=CA,quantity=7} |
| 2196 |
\sankeynode{name=US,quantity=8,at={[yshift=\vdist]CA.left},anchor=right} |
| 2197 |
\sankeynode{name=MX,quantity=8,at={[yshift=\vdist]US.left},anchor=right} |
| 2198 |
\sankeynode{name=BR,quantity=8,at={[yshift=\vdist]MX.left},anchor=right} |
| 2199 |
|
| 2200 |
\foreach \country in {CA,US,MX,BR}{ |
| 2201 |
\sankeystart[color=\country]{\country} |
| 2202 |
\sankeyadvance[color=\country]{\country}{\hwidth} |
| 2203 |
} |
| 2204 |
|
| 2205 |
\sankeyfork{CA}{1/CA-to-PT,1/CA-to-GB,5/CA-to-FR} |
| 2206 |
\sankeyfork{US}{1/US-to-PT,1/US-to-SP,5/US-to-GB,1/US-to-FR} |
| 2207 |
\sankeyfork{MX}{1/MX-to-PT,5/MX-to-SP,1/MX-to-GB,1/MX-to-FR} |
| 2208 |
\sankeyfork{BR}{5/BR-to-PT,1/BR-to-SP,1/BR-to-GB,1/BR-to-FR} |
| 2209 |
|
| 2210 |
\sankeynode{name=FR,quantity=11, |
| 2211 |
at={[xshift=\hdist]CA.right},anchor=right} |
| 2212 |
\sankeynode{name=GB,quantity=11, |
| 2213 |
at={[yshift=\vdist]FR.left},anchor=right} |
| 2214 |
\sankeynode{name=SP,quantity=7, |
| 2215 |
at={[yshift=\vdist]GB.left},anchor=right} |
| 2216 |
\sankeynode{name=PT,quantity=8, |
| 2217 |
at={[yshift=\vdist]SP.left},anchor=right} |
| 2218 |
|
| 2219 |
\sankeyfork{FR} |
| 2220 |
{1/FR-from-BR,1/FR-from-MX,1/FR-from-US,5/FR-from-CA,3/FR-from-00} |
| 2221 |
\sankeyfork{GB} |
| 2222 |
{1/GB-from-BR,1/GB-from-MX,5/GB-from-US,1/GB-from-CA,3/GB-from-00} |
| 2223 |
\sankeyfork{SP}{1/SP-from-BR,5/SP-from-MX,1/SP-from-US} |
| 2224 |
\sankeyfork{PT}{5/PT-from-BR,1/PT-from-MX,1/PT-from-US,1/PT-from-CA} |
| 2225 |
|
| 2226 |
\foreach \country in {FR,GB,SP,PT}{ |
| 2227 |
\sankeyadvance[color=\country]{\country}{\hwidth} |
| 2228 |
} |
| 2229 |
|
| 2230 |
\sankeyfork{FR}{1/FR-to-ZA,1/FR-to-AO,3/FR-to-MA,3/FR-to-SN,3/FR-to-ML} |
| 2231 |
\sankeyfork{GB}{7/GB-to-ZA,1/GB-to-AO,2/GB-to-MA,1/GB-to-SN} |
| 2232 |
\sankeyfork{SP}{1/SP-to-ZA,3/SP-to-MA,1/SP-to-SN,2/SP-to-00} |
| 2233 |
\sankeyfork{PT}{3/PT-to-ZA,2/PT-to-AO,1/PT-to-MA,1/PT-to-SN,1/PT-to-00} |
| 2234 |
|
| 2235 |
\sankeynode{name=ML,quantity=9, |
| 2236 |
at={[xshift=\hdist]FR.right},anchor=right} |
| 2237 |
\sankeynode{name=SN,quantity=9, |
| 2238 |
at={[yshift=\vdist]ML.left},anchor=right} |
| 2239 |
\sankeynode{name=MA,quantity=9, |
| 2240 |
at={[yshift=\vdist]SN.left},anchor=right} |
| 2241 |
\sankeynode{name=AO,quantity=9, |
| 2242 |
at={[yshift=\vdist]MA.left},anchor=right} |
| 2243 |
\sankeynode{name=ZA,quantity=12, |
| 2244 |
at={[yshift=\vdist]AO.left},anchor=right} |
| 2245 |
|
| 2246 |
\sankeyfork{ML}{3/ML-from-FR,6/Mail-from-00} |
| 2247 |
\sankeyfork{SN} |
| 2248 |
{1/SN-from-PT,1/SN-from-SP,1/SN-from-GB,3/SN-from-FR,3/SN-from-00} |
| 2249 |
\sankeyfork{MA}{1/MA-from-PT,3/MA-from-SP,2/MA-from-GB,3/MA-from-FR} |
| 2250 |
\sankeyfork{AO}{2/AO-from-PT,1/AO-from-GB,1/AO-from-FR,5/AO-from-00} |
| 2251 |
\sankeyfork{ZA}{3/ZA-from-PT,1/ZA-from-SP,7/ZA-from-GB,1/ZA-from-FR} |
| 2252 |
|
| 2253 |
\foreach \country in {ML,SN,MA,AO,ZA}{ |
| 2254 |
\sankeyadvance[color=\country]{\country}{\hwidth} |
| 2255 |
} |
| 2256 |
|
| 2257 |
\sankeyfork{ML}{5/ML-to-CN,3/ML-to-JP,1/ML-to-IN} |
| 2258 |
\sankeyfork{SN}{5/SN-to-CN,3/SN-to-JP,1/SN-to-IN} |
| 2259 |
\sankeyfork{MA}{5/MA-to-CN,3/MA-to-JP,1/MA-to-IN} |
| 2260 |
\sankeyfork{AO}{5/AO-to-CN,3/AO-to-JP,1/AO-to-IN} |
| 2261 |
\sankeyfork{ZA}{5/ZA-to-CN,3/ZA-to-JP,1/ZA-to-IN,3/ZA-to-00} |
| 2262 |
|
| 2263 |
\sankeynode{name=IN,quantity=5, |
| 2264 |
at={[xshift=\hdist]ML.right},anchor=right} |
| 2265 |
\sankeynode{name=JP,quantity=15, |
| 2266 |
at={[yshift=\vdist]IN.left},anchor=right} |
| 2267 |
\sankeynode{name=CN,quantity=25, |
| 2268 |
at={[yshift=\vdist]JP.left},anchor=right} |
| 2269 |
|
| 2270 |
\sankeyfork{IN} |
| 2271 |
{1/IN-from-ZA,1/IN-from-AO,1/IN-from-MA,1/IN-from-SN,1/IN-from-ML} |
| 2272 |
\sankeyfork{JP} |
| 2273 |
{3/JP-from-ZA,3/JP-from-AO,3/JP-from-MA,3/JP-from-SN,3/JP-from-ML} |
| 2274 |
\sankeyfork{CN} |
| 2275 |
{5/CN-from-ZA,5/CN-from-AO,5/CN-from-MA,5/CN-from-SN,5/CN-from-ML} |
| 2276 |
|
| 2277 |
\foreach \country in {IN,JP,CN}{ |
| 2278 |
\sankeyadvance[color=\country]{\country}{\hwidth} |
| 2279 |
\sankeyend[color=\country]{\country} |
| 2280 |
} |
| 2281 |
|
| 2282 |
\foreach \startcountry/\countries in { |
| 2283 |
CA/{PT,GB,FR}, US/{PT,SP,GB,FR}, MX/{PT,SP,GB,FR}, |
| 2284 |
BR/{PT,SP,GB,FR}, FR/{ML,SN,MA,AO,ZA}, GB/{SN,MA,AO,ZA}, |
| 2285 |
SP/{SN,MA,ZA}, PT/{SN,MA,AO,ZA}, ML/{IN,JP,CN}, |
| 2286 |
SN/{IN,JP,CN}, MA/{IN,JP,CN}, AO/{IN,JP,CN}, |
| 2287 |
ZA/{IN,JP,CN}} |
| 2288 |
{ |
| 2289 |
\foreach \endcountry in \countries { |
| 2290 |
\sankeyoutin[shade={\startcountry}{\endcountry}] |
| 2291 |
{\startcountry-to-\endcountry}{\endcountry-from-\startcountry} |
| 2292 |
} |
| 2293 |
} |
| 2294 |
|
| 2295 |
|
| 2296 |
\foreach \country/\countryname in {CA/Canada, US/USA, MX/Mexico, |
| 2297 |
BR/Brazil, FR/France, GB/England, SP/Spain, PT/Portugal} |
| 2298 |
{ |
| 2299 |
\node[anchor=south,inner sep=.1em,font=\small] |
| 2300 |
at (\country) {\countryname\vphantom{Ag}}; |
| 2301 |
} |
| 2302 |
|
| 2303 |
\foreach \country/\countryname in { |
| 2304 |
ML/Mali, SN/Senegal, MA/Morocco, AO/Angola, |
| 2305 |
ZA/South Africa, IN/India, JP/Japan, CN/China} |
| 2306 |
{ |
| 2307 |
\node[anchor=south,inner sep=.1em,font=\small] |
| 2308 |
at (\country) {\countryname\vphantom{Ag}}; |
| 2309 |
} |
| 2310 |
\end{sankeydiagram} |
| 2311 |
\end{tikzpicture} |
| 2312 |
%</example3-variation> |
| 2313 |
% \fi |
| 2314 |
% |
| 2315 |
%^^A % ------------------------------------------------------------ |
| 2316 |
% \clearpage |
| 2317 |
% \section{Very nice example -- Nadieh Bremer creation} |
| 2318 |
%^^A % ------------------------------------------------------------ |
| 2319 |
% |
| 2320 |
% \embedfile[mimetype=text/plain]{sankey-example4.tex} |
| 2321 |
% |
| 2322 |
% \begin{figure} |
| 2323 |
% \centering |
| 2324 |
% {\MakePercentComment\input{sankey-example4}} |
| 2325 |
% \caption{Very nice example -- Nadieh Bremer's creation} |
| 2326 |
% (from |
| 2327 |
% \href{https://www.visualcinnamon.com/portfolio/adyen-report-2019/}{Adyen's |
| 2328 |
% Shareholder Report}) |
| 2329 |
% \label{fig:nice-example} |
| 2330 |
% \end{figure} |
| 2331 |
% |
| 2332 |
% Graphic designer Nadieh Bremer created this very nice Sankey |
| 2333 |
% diagram\footnote{\url{https://www.visualcinnamon.com/portfolio/adyen-report-2019/}} |
| 2334 |
% for Adyen's second half 2018 report to shareholders. It is coded here |
| 2335 |
% with her kind permission. |
| 2336 |
% |
| 2337 |
% You can change the data values between lines 27 and 52. |
| 2338 |
% |
| 2339 |
% See figure~\vref{fig:nice-example}. The \code{sankey-example4.tex} |
| 2340 |
% file contains the following code and is an attachement of the current |
| 2341 |
% PDF document. |
| 2342 |
% |
| 2343 |
% \lstinputlisting[numbers=left,style=LaTeXsmall]{sankey-example4} |
| 2344 |
% |
| 2345 |
% \iffalse |
| 2346 |
%<*example4> |
| 2347 |
\begin{tikzpicture} |
| 2348 |
\renewcommand*\sfdefault{txss} |
| 2349 |
\sffamily |
| 2350 |
\sisetup{ |
| 2351 |
detect-all=true, |
| 2352 |
group-separator={,}, |
| 2353 |
group-minimum-digits=4, |
| 2354 |
} |
| 2355 |
% storage of labels |
| 2356 |
\newcommand\LabSet[2]{% node name, label |
| 2357 |
\expandafter\edef\csname#1@Lab\endcsname{#2}} |
| 2358 |
\newcommand\Lab[1]{% node name |
| 2359 |
\csname#1@Lab\endcsname} |
| 2360 |
% storage of quantities |
| 2361 |
\newcommand\QtySet[2]{% node name, quantity |
| 2362 |
\expandafter\edef\csname#1@Qty\endcsname{\fpeval{#2}}} |
| 2363 |
\newcommand\Qty[1]{% node name |
| 2364 |
\csname#1@Qty\endcsname} |
| 2365 |
% all nodes with their name, label and quantity |
| 2366 |
\sankeyset{ |
| 2367 |
def data/.code args={#1/#2/#3}{% node name/label/values |
| 2368 |
\LabSet{#1}{#2} |
| 2369 |
\QtySet{#1}{#3} |
| 2370 |
\typeout{#1: \Qty{#1}€ (\Lab{#1})} |
| 2371 |
}, |
| 2372 |
def data/.list={ |
| 2373 |
{Pf/Processing\\fees/71713}, |
| 2374 |
{Sog/Sales of\\good/4547}, |
| 2375 |
{Sf/Settlement\\fees/842075}, |
| 2376 |
{Os/Other\\services/37532}, |
| 2377 |
{R/Revenues/\Qty{Pf}+\Qty{Sog}+\Qty{Sf}+\Qty{Os}}, |
| 2378 |
{Coi/Cost of Inventory/5151}, |
| 2379 |
{Ciffi/Cost insecure from financial institutions/758234}, |
| 2380 |
{Nr/Net revenue/\Qty{R}-\Qty{Coi}-\Qty{Ciffi}}, |
| 2381 |
{Aadotaifa/Amortization and\\depreciation of tangible and\\ |
| 2382 |
intangible fixed assets/4688}, |
| 2383 |
{Ssapc/Social securities and\\pension costs/7860}, |
| 2384 |
{Was/Wages and salaries/35627}, |
| 2385 |
{Ooe/Other operating expenses/37346}, |
| 2386 |
{Nr2/-/\Qty{Nr}-\Qty{Aadotaifa}-\Qty{Ssapc}-\Qty{Was}-\Qty{Ooe}}, |
| 2387 |
{Oi/Other income/47}, |
| 2388 |
{Ibiiieait/Income before interest income,\\interest expense and |
| 2389 |
income taxes/\Qty{Nr2}+\Qty{Oi}}, |
| 2390 |
{Fe/Finance expense/561}, |
| 2391 |
{Ofr/Other financial results/2533}, |
| 2392 |
{Ibiiieait2/-/\Qty{Ibiiieait}-\Qty{Fe}-\Qty{Ofr}}, |
| 2393 |
{Fi/Finance income/204}, |
| 2394 |
{Ibit/Income before income taxes/\Qty{Ibiiieait2}+\Qty{Fi}}, |
| 2395 |
{It/Income taxes/21134}, |
| 2396 |
{Niftp/Net income for the period/\Qty{Ibit}-\Qty{It}}, |
| 2397 |
{Octa/Other currency\\translation adjustments/785}, |
| 2398 |
{Tci/Total comprehensive income/\Qty{Niftp}+\Qty{Octa}} |
| 2399 |
}, |
| 2400 |
} |
| 2401 |
|
| 2402 |
\definecolor{mygreen}{RGB}{9,192,82} |
| 2403 |
\tikzset{ |
| 2404 |
cost node/.style={ |
| 2405 |
overlay, |
| 2406 |
align=flush center, |
| 2407 |
node font=\footnotesize\sffamily\bfseries, |
| 2408 |
inner sep=0, |
| 2409 |
node contents={% |
| 2410 |
{\mdseries€\,\num{\Qty{#1}}}\\ |
| 2411 |
\Lab{#1}\vphantom{g}% |
| 2412 |
}, |
| 2413 |
}, |
| 2414 |
white hash/.style={ |
| 2415 |
draw=none,fill=none, |
| 2416 |
pattern={Lines[angle=60,line width=2pt,distance=4pt]}, |
| 2417 |
pattern color=white, |
| 2418 |
}, |
| 2419 |
line sep/.style={draw=white,line width=1pt}, |
| 2420 |
left label/.style={left=#1,align=flush right,anchor=north east}, |
| 2421 |
right label/.style={right=#1,align=flush left}, |
| 2422 |
right label hashed/.style={ |
| 2423 |
right=1mm of $(#1.left)!.5!(#1-old.left)$,align=flush left, |
| 2424 |
}, |
| 2425 |
left label hashed/.style={ |
| 2426 |
left=1mm of $(#1.right)!.5!(#1-old.right)$,align=flush right, |
| 2427 |
}, |
| 2428 |
} |
| 2429 |
|
| 2430 |
\newcommand\turnandstop[1]{ |
| 2431 |
\sankeyturn[green to greenwhite]{#1}{-90} |
| 2432 |
\sankeynode{as=#1,name=#1-e,at={#1 -| Coi}} |
| 2433 |
\sankeyoutin[greenwhite to white]{#1}{#1-e} |
| 2434 |
\node[cost node=#1,left label={1mm of #1-e.right}]; |
| 2435 |
} |
| 2436 |
|
| 2437 |
\begin{sankeydiagram}%[debug] |
| 2438 |
\sankeyset{ |
| 2439 |
ratio=28em/1000000, |
| 2440 |
minimum radius=2cm, |
| 2441 |
start style=none, |
| 2442 |
every node/.style={angle=-90}, |
| 2443 |
% default fill and draw styles |
| 2444 |
fill/.style={ |
| 2445 |
line width=0pt, |
| 2446 |
fill=mygreen, |
| 2447 |
}, |
| 2448 |
draw/.style={draw=none}, |
| 2449 |
% specific fill and draw styles |
| 2450 |
green to greenwhite/.style={ |
| 2451 |
fill/.style={ |
| 2452 |
line width=0pt, |
| 2453 |
right color=mygreen, |
| 2454 |
left color=mygreen!20!white, |
| 2455 |
} |
| 2456 |
}, |
| 2457 |
greenwhite to white/.style={ |
| 2458 |
fill/.style={ |
| 2459 |
line width=0pt, |
| 2460 |
right color=mygreen!20!white, |
| 2461 |
left color=mygreen!5!white, |
| 2462 |
} |
| 2463 |
}, |
| 2464 |
dashed/.style={draw/.style={draw=mygreen,dashed}}, |
| 2465 |
} |
| 2466 |
|
| 2467 |
\coordinate (top) at (0,2em); |
| 2468 |
|
| 2469 |
\sankeynodestart{name=Pf,quantity=\Qty{Pf}} |
| 2470 |
\node[cost node=Pf,above=.5em of Pf.center]; |
| 2471 |
|
| 2472 |
\sankeynodestart{name=Sog,quantity=\Qty{Sog}, |
| 2473 |
at={[xshift=4em]Pf.left},anchor=right} |
| 2474 |
\node[cost node=Sog,above=.5em of Sog.center]; |
| 2475 |
|
| 2476 |
\sankeynodestart{name=Sf,quantity=\Qty{Sf}, |
| 2477 |
at={[xshift=2em]Sog.left},anchor=right} |
| 2478 |
\node[cost node=Sf,above=.5em of Sf.center]; |
| 2479 |
|
| 2480 |
\sankeynodestart{name=Os,quantity=\Qty{Os}, |
| 2481 |
at={[xshift=2em]Sf.left},anchor=right} |
| 2482 |
\node[cost node=Os,above=.5em of Os.center]; |
| 2483 |
|
| 2484 |
\sankeynode{ |
| 2485 |
name=R,quantity=\Qty{R},at={[yshift=-10em]Sf.center}, |
| 2486 |
forked={\Qty{Os}/Os-a,\Qty{Sf}/Sf-a,\Qty{Sog}/Sog-a,\Qty{Pf}/Pf-a}, |
| 2487 |
} |
| 2488 |
|
| 2489 |
\foreach \nodename in {Pf,Sog,Sf,Os}{ |
| 2490 |
\sankeyoutin[fill/.style={top color=white,bottom color=mygreen}] |
| 2491 |
{\nodename}{\nodename-a} |
| 2492 |
} |
| 2493 |
|
| 2494 |
\sankeyadvance{R}{1em} |
| 2495 |
\node[cost node=R,right label hashed=R]; |
| 2496 |
|
| 2497 |
\sankeyfork{R}{\Qty{Ciffi}/Ciffi,\Qty{Nr}/Nr,\Qty{Coi}/Coi} |
| 2498 |
|
| 2499 |
\sankeyturnleft[minimum radius=1.cm]{Ciffi}{90} |
| 2500 |
\node[cost node=Ciffi,at={([shift={(1mm,0)}]Ciffi.center)},rotate=-90, |
| 2501 |
anchor=south,align=flush left,node font=\scriptsize\sffamily\bfseries]; |
| 2502 |
|
| 2503 |
\sankeyturnright[green to greenwhite]{Coi}{90} |
| 2504 |
\sankeyadvance[greenwhite to white]{Coi}{1em} |
| 2505 |
\node[cost node=Coi,left={1mm of [yshift=.75ex]Coi.left}, |
| 2506 |
align=flush right,anchor=north east,overlay]; |
| 2507 |
|
| 2508 |
\sankeyadvance{Nr}{9em} |
| 2509 |
\sankeyadvance{Nr}{1em} |
| 2510 |
\node[cost node=Nr,left label hashed=Nr, |
| 2511 |
node font=\large\sffamily\bfseries]; |
| 2512 |
|
| 2513 |
\sankeyfork{Nr}{\Qty{Nr2}/Nr2,\Qty{Ooe}/Ooe, |
| 2514 |
\Qty{Was}/Was,\Qty{Ssapc}/Ssapc,\Qty{Aadotaifa}/Aadotaifa} |
| 2515 |
|
| 2516 |
\turnandstop{Aadotaifa} |
| 2517 |
|
| 2518 |
\sankeyadvance{Ssapc}{5em} |
| 2519 |
\turnandstop{Ssapc} |
| 2520 |
|
| 2521 |
\sankeyadvance{Was}{9em} |
| 2522 |
\turnandstop{Was} |
| 2523 |
|
| 2524 |
\sankeyadvance{Ooe}{12em} |
| 2525 |
\turnandstop{Ooe} |
| 2526 |
|
| 2527 |
\sankeyadvance{Nr2}{15em} |
| 2528 |
\sankeynode{name=Ibiiieait,quantity=\Qty{Ibiiieait}, |
| 2529 |
anchor=right,at={Nr2.right}, |
| 2530 |
forked={\Qty{Oi}/Oi,\Qty{Nr2}/Nr2-e}} |
| 2531 |
|
| 2532 |
\sankeyturnleftbackward[minimum radius=1cm,dashed]{Oi}{90} |
| 2533 |
\node[cost node=Oi,right label=1mm of Oi.left]; |
| 2534 |
|
| 2535 |
\sankeyadvance{Ibiiieait}{1em} |
| 2536 |
\node[cost node=Ibiiieait,right label hashed=Ibiiieait]; |
| 2537 |
|
| 2538 |
\sankeyfork{Ibiiieait} |
| 2539 |
{\Qty{Ibiiieait2}/Ibiiieait2,\Qty{Ofr}/Ofr,\Qty{Fe}/Fe} |
| 2540 |
|
| 2541 |
\turnandstop{Fe} |
| 2542 |
|
| 2543 |
\sankeyadvance{Ofr}{3em} |
| 2544 |
\turnandstop{Ofr} |
| 2545 |
|
| 2546 |
\sankeyadvance{Ibiiieait2}{6em} |
| 2547 |
\sankeynode{name=Ibit,quantity={\Qty{Ibiiieait2}+\Qty{Fi}}, |
| 2548 |
anchor=right,at={Ibiiieait2.right}, |
| 2549 |
forked={\Qty{Fi}/Fi,\Qty{Ibiiieait2}/Ibiiieait2-e}} |
| 2550 |
|
| 2551 |
\sankeyturnleftbackward[minimum radius=1cm,dashed]{Fi}{90} |
| 2552 |
\node[cost node=Fi,right label=1mm of Fi.left]; |
| 2553 |
|
| 2554 |
\sankeyadvance{Ibit}{1em} |
| 2555 |
\node[cost node=Ibit,right label hashed=Ibit]; |
| 2556 |
|
| 2557 |
\sankeyfork{Ibit}{\Qty{Niftp}/Niftp,\Qty{It}/It} |
| 2558 |
|
| 2559 |
\turnandstop{It} |
| 2560 |
|
| 2561 |
\sankeyadvance{Niftp}{6em} |
| 2562 |
|
| 2563 |
\sankeyadvance{Niftp}{1em} |
| 2564 |
\node[cost node=Niftp,right label hashed=Niftp]; |
| 2565 |
|
| 2566 |
\sankeynode{name=Tci,quantity=\Qty{Niftp}+\Qty{Octa}, |
| 2567 |
anchor=right,at={[yshift=-6em]Niftp.right}, |
| 2568 |
forked={\Qty{Octa}/Octa,\Qty{Niftp}/Niftp-e}} |
| 2569 |
\sankeyoutin{Niftp}{Niftp-e} |
| 2570 |
|
| 2571 |
\sankeyturnleftbackward[minimum radius=1cm]{Octa}{90} |
| 2572 |
\node[cost node=Octa,right label=1mm of Octa.left]; |
| 2573 |
|
| 2574 |
\sankeyadvance{Tci}{1em} |
| 2575 |
\node[cost node=Tci,right label hashed=Tci]; |
| 2576 |
|
| 2577 |
\newcommand\hashband[1]{ |
| 2578 |
\draw[line sep] (#1-old.right) -- (#1-old.left); |
| 2579 |
\draw[line sep] (#1.right) -- (#1.left); |
| 2580 |
\path[white hash] (#1-old.right) rectangle (#1.left); |
| 2581 |
} |
| 2582 |
|
| 2583 |
\foreach \nodename in {R,Nr,Nr,Ibiiieait,Ibit,Niftp,Tci}{ |
| 2584 |
\hashband{\nodename} |
| 2585 |
} |
| 2586 |
|
| 2587 |
\end{sankeydiagram} |
| 2588 |
\end{tikzpicture} |
| 2589 |
%</example4> |
| 2590 |
% \fi |
| 2591 |
% |
| 2592 |
% \clearpage |
| 2593 |
% |
| 2594 |
% \StopEventually{} |
| 2595 |
%^^A % ------------------------------------------------------------ |
| 2596 |
% |
| 2597 |
% \manualparts |
| 2598 |
% |
| 2599 |
% \part{Installation \& Implementation} |
| 2600 |
% \label{implementation} |
| 2601 |
%^^A % ------------------------------------------------------------ |
| 2602 |
% |
| 2603 |
% { |
| 2604 |
% \setlength{\parskip}{0pt} |
| 2605 |
% \localtableofcontents |
| 2606 |
% } |
| 2607 |
% |
| 2608 |
% |
| 2609 |
% \changes{v3.0.1}{2022/02/04}{Fix options used by the new version of \protect\code{siunitx} package} |
| 2610 |
% |
| 2611 |
%^^A % ------------------------------------------------------------ |
| 2612 |
% \section{Compiling \ttintitle{sankey}} |
| 2613 |
%^^A % ------------------------------------------------------------ |
| 2614 |
% |
| 2615 |
% \changes{v3.0.1}{2022/02/04}{Add instructions for compiling and installing the |
| 2616 |
% package} |
| 2617 |
% |
| 2618 |
% To produce the \code{sankey} package: |
| 2619 |
% |
| 2620 |
% \begin{lstlisting}[style=bashsmall] |
| 2621 |
% pdflatex sankey.ins # or 'latex sankey.ins' |
| 2622 |
% \end{lstlisting} |
| 2623 |
% |
| 2624 |
% To finish the installation you have to move the |
| 2625 |
% \code{tikzlibrarydubins.code.tex} and |
| 2626 |
% \code{sankey.sty} files into a directory searched by \LaTeX. |
| 2627 |
% |
| 2628 |
% To compile the \code{sankey} documentation (the |
| 2629 |
% \code{sankey.pdf} file): |
| 2630 |
% |
| 2631 |
% \begin{lstlisting}[style=bashsmall] |
| 2632 |
% pdflatex sankey.dtx |
| 2633 |
% makeindex -s gind.ist -o sankey.ind sankey.idx |
| 2634 |
% pdflatex sankey.dtx |
| 2635 |
% makeindex -s gind.ist -o sankey.ind sankey.idx |
| 2636 |
% pdflatex sankey.dtx |
| 2637 |
% pdflatex sankey.dtx |
| 2638 |
% \end{lstlisting} |
| 2639 |
% |
| 2640 |
% |
| 2641 |
%^^A % ------------------------------------------------------------ |
| 2642 |
% \section{The \ttintitle{sankey.sty} file} |
| 2643 |
%^^A % ------------------------------------------------------------ |
| 2644 |
% |
| 2645 |
% Poorly commented source code... |
| 2646 |
% |
| 2647 |
% \changes{v1.0}{2016/03/06}{First version} |
| 2648 |
% \changes{v2.0}{2021/01/27}{First public version (on \CTAN)} |
| 2649 |
% \changes{v3.0}{2021/03/14}{Better naming rule} |
| 2650 |
% \changes{v3.0}{2021/03/14}{Use \protect\code{.ins} and \protect\code{.dtx} files} |
| 2651 |
% |
| 2652 |
% \iffalse |
| 2653 |
%<*sankey> |
| 2654 |
% \fi |
| 2655 |
% |
| 2656 |
% Version information: |
| 2657 |
% |
| 2658 |
% \begin{macrocode} |
| 2659 |
\NeedsTeXFormat{LaTeX2e}[2015/10/01] |
| 2660 |
\ProvidesPackage{sankey}[2025/01/10 v3.0.2 to draw Sankey diagrams] |
| 2661 |
% \end{macrocode} |
| 2662 |
% |
| 2663 |
% All required packages and TikZ libraries: |
| 2664 |
% \begin{macrocode} |
| 2665 |
\RequirePackage{xparse} |
| 2666 |
\RequirePackage{etoolbox} |
| 2667 |
\RequirePackage{xfp} |
| 2668 |
\RequirePackage{tikz} |
| 2669 |
\usetikzlibrary{ |
| 2670 |
calc, |
| 2671 |
decorations.markings, |
| 2672 |
dubins |
| 2673 |
} |
| 2674 |
% \end{macrocode} |
| 2675 |
% |
| 2676 |
% Declarations of PGF layers (to debug Sankey diagrams): |
| 2677 |
% |
| 2678 |
% \begin{macrocode} |
| 2679 |
%% add a new layer to debug sankey diagrams |
| 2680 |
\pgfdeclarelayer{background} |
| 2681 |
\pgfdeclarelayer{foreground} |
| 2682 |
\pgfdeclarelayer{sankeydebug} |
| 2683 |
\pgfsetlayers{background,main,foreground,sankeydebug} |
| 2684 |
% \end{macrocode} |
| 2685 |
% |
| 2686 |
% |
| 2687 |
%^^A % ------------------------------------------------------------ |
| 2688 |
% \subsection{Fields} |
| 2689 |
%^^A % ------------------------------------------------------------ |
| 2690 |
% |
| 2691 |
% \begin{macro}{\snk@newfield} |
| 2692 |
% |
| 2693 |
% The \code{sankeynewfield} macro defines |
| 2694 |
% setter and getter macros for \emph{key}/\emph{value} pairs. |
| 2695 |
% It requires five parameters: the \emph{def} macro used to |
| 2696 |
% store a new value, the \emph{setter} macro name, the \emph{getter} macro name, |
| 2697 |
% the \emph{cs name} used by the new field (including a \texttt{\#1} |
| 2698 |
% parameter -- the \emph{key}) and the \emph{error message} (used by the getter |
| 2699 |
% macro if the key is not defined). |
| 2700 |
% |
| 2701 |
% The \emph{setter} macro requires |
| 2702 |
% two parameters: the key and the value. |
| 2703 |
% The \emph{getter} macro requires |
| 2704 |
% one parameter: the key. |
| 2705 |
% |
| 2706 |
% \begin{macrocode} |
| 2707 |
\def\snk@newfield#1#2#3#4#5{ |
| 2708 |
% setter |
| 2709 |
\def#2##1##2{\expandafter#1\csname #4\endcsname{##2}} |
| 2710 |
% getter |
| 2711 |
\def#3##1{% |
| 2712 |
\ifcsdef{#4}{% |
| 2713 |
\csname#4\endcsname% |
| 2714 |
}{% |
| 2715 |
\PackageError{sankey}{#5}{unknown key with \string#3}% |
| 2716 |
}% |
| 2717 |
} |
| 2718 |
} |
| 2719 |
% \end{macrocode} |
| 2720 |
% \end{macro} |
| 2721 |
% |
| 2722 |
%^^A % ------------------------------------------------------------ |
| 2723 |
% \subsubsection{Definition of \emph{global} and \emph{expanded} fields (using |
| 2724 |
% \ttintitle{\protect\string\xdef})} |
| 2725 |
%^^A % ------------------------------------------------------------ |
| 2726 |
% |
| 2727 |
% \begin{macro}{\snk@setnodeqty} |
| 2728 |
% \begin{macro}{\sankeygetnodeqty} |
| 2729 |
% The setter and getter macros to store and retrieve |
| 2730 |
% the \emph{quantity} field associated with |
| 2731 |
% each Sankey node (the key is the name of the Sankey node). |
| 2732 |
% \begin{macrocode} |
| 2733 |
\snk@newfield\xdef\snk@setnodeqty\sankeygetnodeqty% |
| 2734 |
{@snk@node@qty@#1}{Unknown sankey node '#1'} |
| 2735 |
% \end{macrocode} |
| 2736 |
% \end{macro} |
| 2737 |
% \end{macro} |
| 2738 |
% |
| 2739 |
% \begin{macro}{\snk@setnodeorient} |
| 2740 |
% \begin{macro}{\sankeygetnodeorient} |
| 2741 |
% The setter and getter macros to store and retrieve |
| 2742 |
% the \emph{angle} (or orientation) field |
| 2743 |
% associated with each Sankey node (the key is the name of the Sankey node). |
| 2744 |
% \begin{macrocode} |
| 2745 |
\snk@newfield\xdef\snk@setnodeorient\sankeygetnodeorient% |
| 2746 |
{@snk@node@orient@#1}{Unknown sankey node '#1'} |
| 2747 |
% \end{macrocode} |
| 2748 |
% \end{macro} |
| 2749 |
% \end{macro} |
| 2750 |
% |
| 2751 |
%^^A % ------------------------------------------------------------ |
| 2752 |
% \subsubsection{Definitions of \emph{local} fields (using \ttintitle{\protect\string\def})} |
| 2753 |
%^^A % ------------------------------------------------------------ |
| 2754 |
% |
| 2755 |
% \begin{macro}{\snk@setstartfill} |
| 2756 |
% \begin{macro}{\snk@getstartfill} |
| 2757 |
% \begin{macro}{\snk@setstartdraw} |
| 2758 |
% \begin{macro}{\snk@getstartdraw} |
| 2759 |
% The setter and getter macros to store and retrieve the starting fill/draw |
| 2760 |
% paths (the key is the style name). |
| 2761 |
% \begin{macrocode} |
| 2762 |
\snk@newfield\def\snk@setstartfill\snk@getstartfill% |
| 2763 |
{@snk@start@fill@#1}{Unknown sankey start fill path #1} |
| 2764 |
|
| 2765 |
\snk@newfield\def\snk@setstartdraw\snk@getstartdraw% |
| 2766 |
{@snk@start@draw@#1}{Unknown sankey start draw path #1} |
| 2767 |
% \end{macrocode} |
| 2768 |
% \end{macro} |
| 2769 |
% \end{macro} |
| 2770 |
% \end{macro} |
| 2771 |
% \end{macro} |
| 2772 |
% |
| 2773 |
% \begin{macro}{\snk@setendfill} |
| 2774 |
% \begin{macro}{\snk@getendfill} |
| 2775 |
% \begin{macro}{\snk@setenddraw} |
| 2776 |
% \begin{macro}{\snk@getenddraw} |
| 2777 |
% The setter and getter macros to store and retrieve the ending fill/draw |
| 2778 |
% paths (the key is the style name). |
| 2779 |
% \begin{macrocode} |
| 2780 |
\snk@newfield\def\snk@setendfill\snk@getendfill% |
| 2781 |
{@snk@end@fill@#1}{Unknown sankey end fill path #1} |
| 2782 |
|
| 2783 |
\snk@newfield\def\snk@setenddraw\snk@getenddraw% |
| 2784 |
{@snk@end@draw@#1}{Unknown sankey end draw path #1} |
| 2785 |
% \end{macrocode} |
| 2786 |
% \end{macro} |
| 2787 |
% \end{macro} |
| 2788 |
% \end{macro} |
| 2789 |
% \end{macro} |
| 2790 |
% |
| 2791 |
%^^A % ------------------------------------------------------------ |
| 2792 |
% \subsubsection{Check if a sankey node is defined} |
| 2793 |
%^^A % ------------------------------------------------------------ |
| 2794 |
% |
| 2795 |
% \begin{macro}{\snk@ifnodedefined} |
| 2796 |
|
| 2797 |
% The \code{\snk@ifnodedefined} macro checks if a Sankey |
| 2798 |
% node is defined by checking if its name is associated to |
| 2799 |
% a \emph{quantity}. |
| 2800 |
% \begin{macrocode} |
| 2801 |
\newcommand\snk@ifnodedefined[3]{% |
| 2802 |
\ifcsdef{@snk@node@qty@#1}{#2}{#3}% |
| 2803 |
} |
| 2804 |
% \end{macrocode} |
| 2805 |
% \end{macro} |
| 2806 |
% |
| 2807 |
% \begin{macro}{\snk@errorifnotdefined} |
| 2808 |
% The \code{\snk@errorifnotdefined} macro generares |
| 2809 |
% an error message if the Sankye node is not defined. |
| 2810 |
% \begin{macrocode} |
| 2811 |
\newcommand\snk@errorifnotdefined[1]{% |
| 2812 |
\snk@ifnodedefined{#1}{}% |
| 2813 |
{\PackageError{sankey}{Unknown sankey node '#1'}{}}% |
| 2814 |
} |
| 2815 |
% \end{macrocode} |
| 2816 |
% \end{macro} |
| 2817 |
% |
| 2818 |
%^^A % ------------------------------------------------------------ |
| 2819 |
% \subsection{The \ttintitle{sankey node} shape} |
| 2820 |
%^^A % ------------------------------------------------------------ |
| 2821 |
% |
| 2822 |
% |
| 2823 |
% A \code{sankey node} is defined as a TikZ node |
| 2824 |
% with a particular \emph{shape}: its width is null and its |
| 2825 |
% height matches the associated \emph{quantity}. |
| 2826 |
% This shape requires only three anchors: \code{center}, \code{left} |
| 2827 |
% and \code{right}. |
| 2828 |
% These threee anchors are sufficient to use the |
| 2829 |
% \code{sankey} package. But the \code{fit} library needs |
| 2830 |
% anchors defined by rectangular node. |
| 2831 |
% |
| 2832 |
% \begin{macrocode} |
| 2833 |
\pgfdeclareshape{sankey node}{ |
| 2834 |
\inheritsavedanchors[from=rectangle] |
| 2835 |
\inheritanchor[from=rectangle]{center} |
| 2836 |
\inheritanchorborder[from=rectangle] |
| 2837 |
\anchor{left}{\pgf@process{\northeast}} |
| 2838 |
\anchor{right}{\pgf@process{\southwest}} |
| 2839 |
% compatibility with 'fit' library |
| 2840 |
\inheritanchor[from=rectangle]{west} |
| 2841 |
\inheritanchor[from=rectangle]{east} |
| 2842 |
\inheritanchor[from=rectangle]{north} |
| 2843 |
\inheritanchor[from=rectangle]{south} |
| 2844 |
\inheritanchor[from=rectangle]{north west} |
| 2845 |
\inheritanchor[from=rectangle]{south east} |
| 2846 |
\inheritanchor[from=rectangle]{north east} |
| 2847 |
\inheritanchor[from=rectangle]{south west} |
| 2848 |
} |
| 2849 |
% \end{macrocode} |
| 2850 |
% |
| 2851 |
%^^A % ------------------------------------------------------------ |
| 2852 |
% \subsection{Keys} |
| 2853 |
%^^A % ------------------------------------------------------------ |
| 2854 |
% |
| 2855 |
% \begin{macro}{\sankeyset} |
| 2856 |
% The \code{sankey} package uses \code{pgfkeys} to set options via |
| 2857 |
% \emph{key=value} pairs using the \texttt{/sankey} path |
| 2858 |
% (for Sankey diagram options) and using the |
| 2859 |
% \texttt{/sankey/node parameters} path (for Sankey node parameters). |
| 2860 |
% |
| 2861 |
% The \code{\sankeyset} macro processes |
| 2862 |
% its parameter as a list of comma separated pairs of the form |
| 2863 |
% \emph{key=value} with \texttt{/sankey} as default path. |
| 2864 |
% |
| 2865 |
% \begin{macrocode} |
| 2866 |
\pgfkeys{/sankey/.is family} |
| 2867 |
\NewDocumentCommand\sankeyset{m}{\pgfkeys{sankey,#1}} |
| 2868 |
% \end{macrocode} |
| 2869 |
% \end{macro} |
| 2870 |
% |
| 2871 |
%^^A % ------------------------------------------------------------ |
| 2872 |
% \subsubsection{Keys to define the scale} |
| 2873 |
%^^A % ------------------------------------------------------------ |
| 2874 |
% \begin{macro}{\snk@totalqty} |
| 2875 |
% \begin{macro}{\snk@totallen} |
| 2876 |
% |
| 2877 |
% The \code{ratio quantity}, \code{ratio length} and |
| 2878 |
% \code{ratio} keys define the ratio between |
| 2879 |
% \emph{flow quantity} and \emph{graphic length} (the scale). |
| 2880 |
% The \code{\snk@totalqty} and \code{\snk@totallen} macros store the values. |
| 2881 |
% All \emph{quantities} are processed by \code{\fpeval} and |
| 2882 |
% all \emph{lengths} are processed by \code{pgfmath}. |
| 2883 |
% \begin{macrocode} |
| 2884 |
\sankeyset{ |
| 2885 |
ratio quantity/.code={\edef\snk@totalqty{\fpeval{#1}}}, |
| 2886 |
ratio quantity/.value required, |
| 2887 |
ratio length/.code={ |
| 2888 |
\pgfmathsetmacro\snk@totallen{#1} |
| 2889 |
\edef\snk@totallen{\snk@totallen pt} |
| 2890 |
}, |
| 2891 |
ratio length/.value required, |
| 2892 |
ratio/.style args={#1/#2}{ |
| 2893 |
ratio length=#1, |
| 2894 |
ratio quantity=#2, |
| 2895 |
}, |
| 2896 |
ratio/.value required, |
| 2897 |
} |
| 2898 |
% \end{macrocode} |
| 2899 |
% \end{macro} |
| 2900 |
% \end{macro} |
| 2901 |
% |
| 2902 |
%^^A % ------------------------------------------------------------ |
| 2903 |
% \subsubsection{Rotate offset} |
| 2904 |
%^^A % ------------------------------------------------------------ |
| 2905 |
% |
| 2906 |
% \begin{macro}{\snk@rotate} |
| 2907 |
% |
| 2908 |
% The \code{rotate} key stores an offset angle applied to all Sankey |
| 2909 |
% nodes. This is useful when using the \code{rotate} option within a |
| 2910 |
% \code{tikzpicture} or a \code{scope}. This TikZ option is only |
| 2911 |
% applied to coordinates and not to TikZ nodes (remember that Sankey |
| 2912 |
% nodes are TikZ nodes). It's up to the author to keep the |
| 2913 |
% \code{rotate} option of the \code{tikzpicture} and that of the |
| 2914 |
% \code{sankeydiagram} synchronous. |
| 2915 |
% |
| 2916 |
% \begin{macrocode} |
| 2917 |
\sankeyset{ |
| 2918 |
rotate/.code={\edef\snk@rotate{\fpeval{#1}}}, |
| 2919 |
rotate/.value required, |
| 2920 |
} |
| 2921 |
% \end{macrocode} |
| 2922 |
% \end{macro} |
| 2923 |
% |
| 2924 |
%^^A % ------------------------------------------------------------ |
| 2925 |
% \subsubsection{Minimum radius} |
| 2926 |
%^^A % ------------------------------------------------------------ |
| 2927 |
% |
| 2928 |
% \begin{macro}{\snk@minradius} |
| 2929 |
% |
| 2930 |
% The \code{minimum radius} key processes the minimum radius |
| 2931 |
% of curvature by \code{pgfmath} then stores it in |
| 2932 |
% the \code{\snk@minradius} macro. |
| 2933 |
% \begin{macrocode} |
| 2934 |
\sankeyset{ |
| 2935 |
minimum radius/.code={ |
| 2936 |
\pgfmathsetmacro\snk@minradius{#1} |
| 2937 |
\edef\snk@minradius{\snk@minradius pt} |
| 2938 |
}, |
| 2939 |
minimum radius/.value required, |
| 2940 |
} |
| 2941 |
% \end{macrocode} |
| 2942 |
% \end{macro} |
| 2943 |
% |
| 2944 |
%^^A % ------------------------------------------------------------ |
| 2945 |
% \subsubsection{Outin step} |
| 2946 |
%^^A % ------------------------------------------------------------ |
| 2947 |
% |
| 2948 |
% \begin{macro}{\snk@stepoutin} |
| 2949 |
% The \code{outin} key stores its value in |
| 2950 |
% the \code{\snk@stepoutin} macro. |
| 2951 |
% |
| 2952 |
% \begin{macrocode} |
| 2953 |
\sankeyset{ |
| 2954 |
outin steps/.estore in=\snk@stepoutin, |
| 2955 |
outon steps/.value required, |
| 2956 |
} |
| 2957 |
% \end{macrocode} |
| 2958 |
% \end{macro} |
| 2959 |
% |
| 2960 |
%^^A % ------------------------------------------------------------ |
| 2961 |
% \subsubsection{Sankey debug} |
| 2962 |
%^^A % ------------------------------------------------------------ |
| 2963 |
% |
| 2964 |
% |
| 2965 |
% The \code{debug} key drives the \code{sankey debug} toggle. |
| 2966 |
% |
| 2967 |
% \begin{macrocode} |
| 2968 |
\newtoggle{sankey debug} |
| 2969 |
\sankeyset{ |
| 2970 |
debug/.is choice, |
| 2971 |
debug/true/.code={\toggletrue{sankey debug}}, |
| 2972 |
debug/false/.code={\togglefalse{sankey debug}}, |
| 2973 |
debug/.default=true, |
| 2974 |
} |
| 2975 |
% \end{macrocode} |
| 2976 |
% |
| 2977 |
%^^A % ------------------------------------------------------------ |
| 2978 |
% \subsubsection{Start and end styles} |
| 2979 |
%^^A % ------------------------------------------------------------ |
| 2980 |
% |
| 2981 |
% \begin{macro}{\snk@startstyle} |
| 2982 |
% \begin{macro}{\snk@endstyle} |
| 2983 |
% The \code{start style} and \code{end style} keys are choices. |
| 2984 |
% |
| 2985 |
% The \code{new start style} and \code{new end style} keys |
| 2986 |
% add new option to these choices. |
| 2987 |
% They use the \code{startfill}, \code{startdraw} fields |
| 2988 |
% or the \code{endfill} and \code{enddraw} |
| 2989 |
% fields (using the style \emph{name} as key) to store the fill and draw |
| 2990 |
% paths then create a new option to install the new |
| 2991 |
% start (\code{\snk@startstyle}) or end (\code{\snk@endstyle}) style. |
| 2992 |
% |
| 2993 |
% \begin{macrocode} |
| 2994 |
\sankeyset{ |
| 2995 |
start style/.is choice, |
| 2996 |
end style/.is choice, |
| 2997 |
% to define new start and end styles |
| 2998 |
new start style/.code n args={3}{% name, fill path, draw path |
| 2999 |
\snk@setstartfill{#1}{#2} |
| 3000 |
\snk@setstartdraw{#1}{#3} |
| 3001 |
\sankeyset{start style/#1/.code={\def\snk@startstyle{#1}}} |
| 3002 |
}, |
| 3003 |
new end style/.code n args={3}{% name, fill path, draw path |
| 3004 |
\snk@setendfill{#1}{#2} |
| 3005 |
\snk@setenddraw{#1}{#3} |
| 3006 |
\sankeyset{end style/#1/.code={\def\snk@endstyle{#1}}} |
| 3007 |
}, |
| 3008 |
} |
| 3009 |
% \end{macrocode} |
| 3010 |
% \end{macro} |
| 3011 |
% \end{macro} |
| 3012 |
% |
| 3013 |
%^^A % ------------------------------------------------------------ |
| 3014 |
% \subsubsection{Initial parameters} |
| 3015 |
%^^A % ------------------------------------------------------------ |
| 3016 |
% |
| 3017 |
% The \code{@initial options} style defines default values for |
| 3018 |
% options of Sankey diagram. The \code{every diagram} style (initially |
| 3019 |
% empty) allows the user to choose its own default values. |
| 3020 |
% |
| 3021 |
% The \code{@initial options} and the \code{every diagram} styles are |
| 3022 |
% applied (in this order) at the beginning of each Sankey diagram. |
| 3023 |
% |
| 3024 |
% \begin{macrocode} |
| 3025 |
\sankeyset{ |
| 3026 |
debug color/.style={/utils/exec={\colorlet{debug color}{#1}}}, |
| 3027 |
@initial options/.style={ |
| 3028 |
ratio=1cm/10, |
| 3029 |
minimum radius=5mm,% |
| 3030 |
outin steps=10, |
| 3031 |
debug=false, |
| 3032 |
start style=none, |
| 3033 |
end style=none, |
| 3034 |
rotate=0, |
| 3035 |
% default fill/draw styles, |
| 3036 |
fill/.style={line width=0pt,fill=white}, |
| 3037 |
draw/.style={draw=black,line width=.4pt}, |
| 3038 |
% debug color used by all debug macros |
| 3039 |
debug color=red!75!black, |
| 3040 |
% debug line between left and right anchors |
| 3041 |
debug line/.style={overlay,draw=debug color,|-|}, |
| 3042 |
% debug line between center and label |
| 3043 |
debug normal/.style={overlay,draw=debug color}, |
| 3044 |
% debug node label |
| 3045 |
debug label/.style={ |
| 3046 |
overlay, |
| 3047 |
draw, |
| 3048 |
font=\ttfamily\tiny, |
| 3049 |
text=debug color,text opacity=1, |
| 3050 |
inner sep=.1em, |
| 3051 |
fill=white,fill opacity=1, |
| 3052 |
rounded corners=.1em, |
| 3053 |
node contents={\name}, |
| 3054 |
}, |
| 3055 |
every node/.style={}, |
| 3056 |
}, |
| 3057 |
every diagram/.style={}, |
| 3058 |
} |
| 3059 |
|
| 3060 |
% \end{macrocode} |
| 3061 |
% |
| 3062 |
%^^A % ------------------------------------------------------------ |
| 3063 |
% \subsubsection{Sankey node parameters} |
| 3064 |
%^^A % ------------------------------------------------------------ |
| 3065 |
% |
| 3066 |
% The \code{/sankey/node parameters} family defines all parameters during |
| 3067 |
% creation of Sankey node. |
| 3068 |
% |
| 3069 |
% \begin{macrocode} |
| 3070 |
\sankeyset{node parameters/.is family} |
| 3071 |
% \end{macrocode} |
| 3072 |
% \begin{macro}{\name} |
| 3073 |
% \begin{macro}{\qty} |
| 3074 |
% \begin{macro}{\orient} |
| 3075 |
% \begin{macro}{\pos} |
| 3076 |
% |
| 3077 |
% The \code{name}, \code{quantity}, \code{angle} and \code{at} keys use the |
| 3078 |
% \code{\name}, \code{\qty}, \code{\orient} and \code{\pos} macros |
| 3079 |
% to store the \emph{name}, the \emph{quantity}, the \emph{orientation} (or |
| 3080 |
% \emph{angle}) and the \emph{position} of a Sankey node during its |
| 3081 |
% creation. |
| 3082 |
% |
| 3083 |
% The \emph{quantity} is processed via \code{\fpeval}. The |
| 3084 |
% \emph{orientation} is normalized. |
| 3085 |
% |
| 3086 |
% \begin{macrocode} |
| 3087 |
\sankeyset{node parameters, |
| 3088 |
name/.estore in=\name, |
| 3089 |
name/.value required, |
| 3090 |
quantity/.code={\edef\qty{\fpeval{#1}}}, |
| 3091 |
quantity/.value required, |
| 3092 |
angle/.code={\edef\orient{\snk@normalize@angle{#1}}}, |
| 3093 |
angle/.value required, |
| 3094 |
at/.code={\snk@getpos\pos{#1}}, |
| 3095 |
at/.value required, |
| 3096 |
} |
| 3097 |
% \end{macrocode} |
| 3098 |
% \end{macro} |
| 3099 |
% \end{macro} |
| 3100 |
% \end{macro} |
| 3101 |
% \end{macro} |
| 3102 |
% |
| 3103 |
% The \code{as} key is just a shortcut to define the four current node |
| 3104 |
% parameters by copying them from an existing Sankey node. |
| 3105 |
% |
| 3106 |
% \begin{macrocode} |
| 3107 |
\sankeyset{node parameters, |
| 3108 |
as/.style={ |
| 3109 |
name=#1, |
| 3110 |
quantity=\sankeygetnodeqty{#1}, |
| 3111 |
angle=\sankeygetnodeorient{#1}, |
| 3112 |
at={#1.center}, |
| 3113 |
}, |
| 3114 |
as/.value required, |
| 3115 |
} |
| 3116 |
% \end{macrocode} |
| 3117 |
% |
| 3118 |
% \begin{macro}{\snk@anchor} |
| 3119 |
% |
| 3120 |
% The \code{anchor} key stores in the \code{\snk@anchor} macro |
| 3121 |
% the anchor name to use to create the new current Sankey node |
| 3122 |
% |
| 3123 |
% \begin{macrocode} |
| 3124 |
\sankeyset{node parameters, |
| 3125 |
anchor/.is choice, |
| 3126 |
anchor/left/.code={\def\snk@anchor{left}}, |
| 3127 |
anchor/right/.code={\def\snk@anchor{right}}, |
| 3128 |
anchor/center/.code={\def\snk@anchor{center}}, |
| 3129 |
anchor/.value required, |
| 3130 |
} |
| 3131 |
% \end{macrocode} |
| 3132 |
% \end{macro} |
| 3133 |
% |
| 3134 |
% The \code{start} and \code{end} keys drive the |
| 3135 |
% \code{sankey node start} and \code{sankey node end} |
| 3136 |
% toggles. |
| 3137 |
% |
| 3138 |
% \begin{macrocode} |
| 3139 |
\newtoggle{sankey node start} |
| 3140 |
\newtoggle{sankey node end} |
| 3141 |
\sankeyset{node parameters, |
| 3142 |
start/.is choice, |
| 3143 |
start/true/.code={\toggletrue{sankey node start}}, |
| 3144 |
start/false/.code={\togglefalse{sankey node start}}, |
| 3145 |
start/.default=true, |
| 3146 |
% |
| 3147 |
end/.is choice, |
| 3148 |
end/true/.code={\toggletrue{sankey node end}}, |
| 3149 |
end/false/.code={\togglefalse{sankey node end}}, |
| 3150 |
end/.default=true, |
| 3151 |
} |
| 3152 |
% \end{macrocode} |
| 3153 |
% \begin{macro}{\snk@listofforks} |
| 3154 |
% \begin{macro}{\snk@forkanchor} |
| 3155 |
% |
| 3156 |
% The \code{forked} and \code{fork anchor} keys store their value in the |
| 3157 |
% \code{\snk@listofforks} and \code{\snk@forkanchor} macros. |
| 3158 |
% |
| 3159 |
% \begin{macrocode} |
| 3160 |
\sankeyset{node parameters, |
| 3161 |
forked/.estore in=\snk@listofforks, |
| 3162 |
forked/.value required, |
| 3163 |
fork anchor/.estore in=\snk@forkanchor, |
| 3164 |
fork anchor/.value required, |
| 3165 |
} |
| 3166 |
% \end{macrocode} |
| 3167 |
% \end{macro} |
| 3168 |
% \end{macro} |
| 3169 |
% |
| 3170 |
% The \code{@initial parameters} style initialises all Sankey node |
| 3171 |
% parameters at the start of the creation of a new Sankey node. |
| 3172 |
% |
| 3173 |
% \begin{macrocode} |
| 3174 |
\sankeyset{node parameters, |
| 3175 |
@initial parameters/.style={ |
| 3176 |
start=false, |
| 3177 |
end=false, |
| 3178 |
forked=, |
| 3179 |
fork anchor=, |
| 3180 |
anchor=center, |
| 3181 |
at={0,0}, |
| 3182 |
angle=0, |
| 3183 |
}, |
| 3184 |
} |
| 3185 |
% \end{macrocode} |
| 3186 |
% |
| 3187 |
% |
| 3188 |
%^^A % ------------------------------------------------------------ |
| 3189 |
% \subsubsection{Internal Tikz style} |
| 3190 |
%^^A % ------------------------------------------------------------ |
| 3191 |
% |
| 3192 |
% To apply this style with Tikz, use absolute key name |
| 3193 |
% (\texttt{/sankey/@sankey node}). This style is used to create the Tikz |
| 3194 |
% node assoicated to a Sankey node. |
| 3195 |
% |
| 3196 |
% \begin{macrocode} |
| 3197 |
\sankeyset{ |
| 3198 |
% sankey node TikZ style |
| 3199 |
@sankey node/.style n args={3}{% name, pos, anchor |
| 3200 |
shape=sankey node, |
| 3201 |
inner sep=0, |
| 3202 |
minimum height={\sankeyqtytolen{\sankeygetnodeqty{#1}}}, |
| 3203 |
minimum width=0, |
| 3204 |
draw=none, |
| 3205 |
line width=0pt, |
| 3206 |
fill=none, |
| 3207 |
node contents={}, |
| 3208 |
rotate=\sankeygetnodeorient{#1}+\snk@rotate, |
| 3209 |
at={(#2)}, |
| 3210 |
name=#1, |
| 3211 |
anchor=#3, |
| 3212 |
}, |
| 3213 |
} |
| 3214 |
% \end{macrocode} |
| 3215 |
% |
| 3216 |
%^^A % ------------------------------------------------------------ |
| 3217 |
% \subsection{Internal macros} |
| 3218 |
%^^A % ------------------------------------------------------------ |
| 3219 |
% |
| 3220 |
% \begin{macro}{\snk@getpos} |
| 3221 |
% |
| 3222 |
% The \code{\snk@getpos} macro extracts the position of a TikZ |
| 3223 |
% node\footnote{Thanks to Andrew Stacey \url{https://tex.stackexchange.com/a/33765/14500}}. |
| 3224 |
% |
| 3225 |
% \begin{macrocode} |
| 3226 |
\def\snk@getpos#1#2{% |
| 3227 |
\tikz@scan@one@point\pgfutil@firstofone(#2)\relax% |
| 3228 |
\edef#1{\the\pgf@x,\the\pgf@y}% |
| 3229 |
} |
| 3230 |
% \end{macrocode} |
| 3231 |
% \end{macro} |
| 3232 |
% |
| 3233 |
% \begin{macro}{\snk@modulo} |
| 3234 |
% |
| 3235 |
% The \code{\snk@modulo} macro evaluates \#1 modulo \#2 using \code{\fpeval}. |
| 3236 |
% |
| 3237 |
% \begin{macrocode} |
| 3238 |
\def\snk@modulo#1#2{\fpeval{#1-(floor((#1)/(#2),0)*#2)}} |
| 3239 |
% \end{macrocode} |
| 3240 |
% \end{macro} |
| 3241 |
% |
| 3242 |
% \begin{macro}{\snk@normalize@angle} |
| 3243 |
% |
| 3244 |
% The \code{\snk@normalize@angle} macro normalizes \#1 (an angle) between |
| 3245 |
% $-180$ and $180$ (using \code{\fpeval}). |
| 3246 |
% |
| 3247 |
% \begin{macrocode} |
| 3248 |
\def\snk@normalize@angle#1{% |
| 3249 |
\fpeval{\snk@modulo{(#1)+180}{360}-180}% |
| 3250 |
} |
| 3251 |
% \end{macrocode} |
| 3252 |
% \end{macro} |
| 3253 |
% |
| 3254 |
% \begin{macro}{\snk@show@debug} |
| 3255 |
% |
| 3256 |
% The \code{snk@show@debug} macro draws debug information |
| 3257 |
% of the Sankey node named \#1 but only if the \code{sankey debug} |
| 3258 |
% toogle is true. Everything is drawn on the \code{sankeydebug} |
| 3259 |
% layer. It uses the \code{/sankey/debug line}, |
| 3260 |
% \code{/sankey/debug normal} and \code{/sankey/debug label} Tikz styles. |
| 3261 |
% |
| 3262 |
% \begin{macrocode} |
| 3263 |
\def\snk@show@debug#1{% node name |
| 3264 |
\iftoggle{sankey debug}{ |
| 3265 |
\begingroup |
| 3266 |
\edef\name{#1} |
| 3267 |
\edef\qty{\sankeygetnodeqty{\name}} |
| 3268 |
\edef\orient{\sankeygetnodeorient{\name}} |
| 3269 |
\begin{pgfonlayer}{sankeydebug} |
| 3270 |
\path[/sankey/debug line] (\name.left) -- (\name.right); |
| 3271 |
\pgfmathsetmacro{\snk@len}{\sankeyqtytolen{\qty}/3} |
| 3272 |
\path[/sankey/debug normal] (\name.center) |
| 3273 |
-- ($(\name.center)!\snk@len pt!90:(\name.right)$) |
| 3274 |
node[/sankey/debug label,rotate=\orient+90+\snk@rotate,anchor=north]; |
| 3275 |
\end{pgfonlayer} |
| 3276 |
\endgroup |
| 3277 |
}{} |
| 3278 |
} |
| 3279 |
% \end{macrocode} |
| 3280 |
% \end{macro} |
| 3281 |
% \begin{macro}{\snk@makeforkednode} |
| 3282 |
% \begin{macro}{\snk@tot} |
| 3283 |
% \begin{macro}{\snk@subnodeqty} |
| 3284 |
% \begin{macro}{\snk@subnodename} |
| 3285 |
% \begin{macro}{\snk@added@values} |
| 3286 |
% |
| 3287 |
% The \code{\snk@makeforkednode} forks a Sankey node. |
| 3288 |
% |
| 3289 |
% \begin{macrocode} |
| 3290 |
\def\snk@makeforkednode{ |
| 3291 |
\begingroup |
| 3292 |
\ifdefempty{\snk@listofforks}{ |
| 3293 |
\ifdefempty{\snk@forkanchor}{}{ |
| 3294 |
\PackageWarning{sankey}% |
| 3295 |
{Can't use 'fork anchor' key without 'forked' key} |
| 3296 |
} |
| 3297 |
}{ |
| 3298 |
\def\snk@tot{0} |
| 3299 |
\def\snk@added@values{} |
| 3300 |
\sankeyset{ |
| 3301 |
@add forked node/.code args={##1/##2}{ |
| 3302 |
\coordinate (##2) at ($(\name.left)% |
| 3303 |
!\fpeval{(\snk@tot+.5*(##1))/\qty}% |
| 3304 |
!(\name.right)$); |
| 3305 |
\edef\snk@orient{\orient} |
| 3306 |
\sankeynode[debug=false] |
| 3307 |
{name=##2,quantity=##1,at=##2,angle=\snk@orient} |
| 3308 |
\edef\snk@tot{\fpeval{\snk@tot+##1}} |
| 3309 |
\edef\snk@added@values{\snk@added@values+##1} |
| 3310 |
}, |
| 3311 |
@add forked node/.list/.expand once=\snk@listofforks, |
| 3312 |
} |
| 3313 |
\edef\snk@diff{\fpeval{abs(\qty-\snk@tot)}} |
| 3314 |
\ifnumequal{\snk@diff}{0}{}{ |
| 3315 |
\PackageWarning{sankey}% |
| 3316 |
{^^J*** Warning: bad sankey fork: % |
| 3317 |
\qty\space!=\space\snk@added@values(=\snk@tot)% |
| 3318 |
^^J\snk@listofforks} |
| 3319 |
} |
| 3320 |
\ifdefempty{\snk@forkanchor}{ |
| 3321 |
\edef\snk@forkanchor{\name.\snk@anchor} |
| 3322 |
}{} |
| 3323 |
\snk@getpos\snk@c{$(\snk@forkanchor) - (\pos)$} |
| 3324 |
\sankeynode{as=\name,at={$(\name) - (\snk@c)$}} |
| 3325 |
\foreach \snk@subnodeqty/\snk@subnodename in \snk@listofforks { |
| 3326 |
\sankeynode{as=\snk@subnodename,at={$(\snk@subnodename) - (\snk@c)$}} |
| 3327 |
} |
| 3328 |
} |
| 3329 |
\endgroup |
| 3330 |
} |
| 3331 |
% \end{macrocode} |
| 3332 |
% \end{macro} |
| 3333 |
% \end{macro} |
| 3334 |
% \end{macro} |
| 3335 |
% \end{macro} |
| 3336 |
% \end{macro} |
| 3337 |
% \begin{macro}{\snk@makenode} |
| 3338 |
% |
| 3339 |
% The \code{\snk@makenode} macro creates a new Sankey node named |
| 3340 |
% \code{\name} with \code{\qty} quantity, oriented at |
| 3341 |
% \code{\orient} degrees (but modified by the \code{\snk@rotate} |
| 3342 |
% angle offset), anchored by its \code{\anchor} (or its \emph{center} |
| 3343 |
% by default) at \code{\pos} position. |
| 3344 |
% |
| 3345 |
% \begin{macrocode} |
| 3346 |
\def\snk@makenode{ |
| 3347 |
\begingroup |
| 3348 |
\snk@setnodeqty{\name}{\qty} |
| 3349 |
\edef\orient{\snk@normalize@angle{\orient}} |
| 3350 |
\snk@setnodeorient{\name}{\orient} |
| 3351 |
\ifundef{\snk@anchor}{\def\snk@anchor{center}}{} |
| 3352 |
\node[/sankey/@sankey node={\name}{\pos}{\snk@anchor}]; |
| 3353 |
\endgroup |
| 3354 |
} |
| 3355 |
% \end{macrocode} |
| 3356 |
% \end{macro} |
| 3357 |
% |
| 3358 |
% \begin{macro}{\snk@filldrawstart} |
| 3359 |
% |
| 3360 |
% The \code{\snk@filldrawstart} macro fills |
| 3361 |
% (with the \code{/sankey/fill} TikZ style) then draws |
| 3362 |
% (with the \code{/sankey/draw} TikZ style) |
| 3363 |
% a start of flow using paths from style \code{\snk@startstyle} on |
| 3364 |
% the Sankey node named \code{\name}. |
| 3365 |
% |
| 3366 |
% \begin{macrocode} |
| 3367 |
\def\snk@filldrawstart{ |
| 3368 |
\begin{scope}[shift={(\name)},rotate=\orient] |
| 3369 |
\path[/sankey/fill] \snk@getstartfill{\snk@startstyle}; |
| 3370 |
\path[/sankey/draw] \snk@getstartdraw{\snk@startstyle}; |
| 3371 |
\end{scope} |
| 3372 |
} |
| 3373 |
% \end{macrocode} |
| 3374 |
% \end{macro} |
| 3375 |
% |
| 3376 |
% \begin{macro}{\snk@filldrawend} |
| 3377 |
% |
| 3378 |
% The \code{\snk@filldrawend} macro fills |
| 3379 |
% (with the \code{/sankey/fill} TikZ style) then draws |
| 3380 |
% (with the \code{/sankey/draw} TikZ style) |
| 3381 |
% a end of flow using paths from style \code{\snk@endstyle} on |
| 3382 |
% the Sankey node named \code{\name}. |
| 3383 |
% |
| 3384 |
% \begin{macrocode} |
| 3385 |
\def\snk@filldrawend{ |
| 3386 |
\begin{scope}[shift={(\name)},rotate=\sankeygetnodeorient{\name}] |
| 3387 |
\path[/sankey/fill] \snk@getendfill{\snk@endstyle}; |
| 3388 |
\path[/sankey/draw] \snk@getenddraw{\snk@endstyle}; |
| 3389 |
\end{scope} |
| 3390 |
} |
| 3391 |
% \end{macrocode} |
| 3392 |
% \end{macro} |
| 3393 |
% |
| 3394 |
% \begin{macro}{\snk@checkquantities} |
| 3395 |
% \begin{macro}{\snk@qtyi} |
| 3396 |
% \begin{macro}{\snk@qtyii} |
| 3397 |
% The \code{\snk@checkquantities} compares quantities |
| 3398 |
% from Sankey nodes \code{#1} and \code{#2} and emits |
| 3399 |
% an error message if they differ (\code{#3} is the name |
| 3400 |
% of the macro which requested the verification). |
| 3401 |
% |
| 3402 |
% \begin{macrocode} |
| 3403 |
\def\snk@checkquantities#1#2#3{ |
| 3404 |
\begingroup |
| 3405 |
\edef\snk@qtyi{\sankeygetnodeqty{#1}} |
| 3406 |
\edef\snk@qtyii{\sankeygetnodeqty{#2}} |
| 3407 |
\ifdefstrequal{\snk@qtyi}{\snk@qtyii}{}{ |
| 3408 |
\PackageError{sankey}% |
| 3409 |
{^^J*** \string#3: quantities differ between % |
| 3410 |
#1 (\snk@qtyi) and #2 (\snk@qtyii)% |
| 3411 |
^^J}% |
| 3412 |
{The quantities of the two Sankey nodes must be equal.} |
| 3413 |
} |
| 3414 |
\endgroup |
| 3415 |
} |
| 3416 |
% \end{macrocode} |
| 3417 |
% \end{macro} |
| 3418 |
% \end{macro} |
| 3419 |
% \end{macro} |
| 3420 |
% |
| 3421 |
%^^A % ------------------------------------------------------------ |
| 3422 |
% \subsection{User macros} |
| 3423 |
%^^A % ------------------------------------------------------------ |
| 3424 |
% |
| 3425 |
% The user macros are globally defined as internal (with \code{snk@} |
| 3426 |
% prefix) and locally defined in the \code{sankeydiagram} environment as |
| 3427 |
% user macros (without the \code{snk@} prefix). |
| 3428 |
% |
| 3429 |
% \begin{macro}{\snk@sankeydubins} |
| 3430 |
% |
| 3431 |
% The \code{\snk@sankeydubins} macro links two Sankey nodes via a |
| 3432 |
% Dubins path. First, it computes the Dubins path between centers |
| 3433 |
% (left and right radii are the same) and stores the result in |
| 3434 |
% \code{sankey}. Then it uses the stored result to fill and draw the |
| 3435 |
% lane (left border and right borders use Dubins paths with asymmetric |
| 3436 |
% radii). |
| 3437 |
% |
| 3438 |
% \begin{macrocode} |
| 3439 |
\NewDocumentCommand\snk@sankeydubins{O{}mm}{% options, sn, en |
| 3440 |
\snk@errorifnotdefined{#2} |
| 3441 |
\snk@errorifnotdefined{#3} |
| 3442 |
\snk@checkquantities{#2}{#3}{\sankeydubins} |
| 3443 |
\begingroup |
| 3444 |
\sankeyset{#1} |
| 3445 |
\pgfmathsetmacro\qty{\sankeygetnodeqty{#2}} |
| 3446 |
\dubinspathset{ |
| 3447 |
sankey/.style={ |
| 3448 |
start point=#2.center,start angle=\sankeygetnodeorient{#2}, |
| 3449 |
end point=#3.center,end angle=\sankeygetnodeorient{#3}, |
| 3450 |
minimum radius=\snk@minradius + .5 * \sankeyqtytolen{\qty} pt, |
| 3451 |
}, |
| 3452 |
} |
| 3453 |
\dubinspathcalc{sankey,store=sankey} |
| 3454 |
\dubinspathset{ |
| 3455 |
left border/.style={ |
| 3456 |
sankey, use store=sankey, |
| 3457 |
left and right minimum radii={\snk@minradius} |
| 3458 |
and {\snk@minradius + \sankeyqtytolen{\qty} pt}, |
| 3459 |
}, |
| 3460 |
right border/.style={ |
| 3461 |
sankey, use store=sankey, |
| 3462 |
left and right minimum radii= |
| 3463 |
{\snk@minradius + \sankeyqtytolen{\qty} pt} |
| 3464 |
and {\snk@minradius}, |
| 3465 |
}, |
| 3466 |
} |
| 3467 |
% fill the region |
| 3468 |
\path[/sankey/fill] (#2.left) \dubinspath{left border} |
| 3469 |
-- (#3.left) -- (#3.right) \dubinspath{right border,reverse} |
| 3470 |
-- (#2.right) -- cycle; |
| 3471 |
% draw left and right borders |
| 3472 |
\path[/sankey/draw] (#2.left) \dubinspath{left border} |
| 3473 |
(#2.right) \dubinspath{right border}; |
| 3474 |
\endgroup |
| 3475 |
} |
| 3476 |
% \end{macrocode} |
| 3477 |
% \end{macro} |
| 3478 |
% |
| 3479 |
% \begin{macro}{\snk@sankeyoutin} |
| 3480 |
% |
| 3481 |
% The \code{\snk@sankeyoutin} macro links two Sankey nodes via a |
| 3482 |
% Bézier curve. First, to simulate constant width, it creates |
| 3483 |
% \code{\snk@stepoutin} intermediate Sankey nodes along the Bézier |
| 3484 |
% curve. Then, the lane is filled and drawn linking all the |
| 3485 |
% intermediate Sankey node via smaller Bézier curves. |
| 3486 |
% |
| 3487 |
% \begin{macrocode} |
| 3488 |
\NewDocumentCommand\snk@sankeyoutin{O{}mm}{% options, sn, en |
| 3489 |
\snk@errorifnotdefined{#2} |
| 3490 |
\snk@errorifnotdefined{#3} |
| 3491 |
\snk@checkquantities{#2}{#3}{\sankeyoutin} |
| 3492 |
\begingroup |
| 3493 |
\sankeyset{#1} |
| 3494 |
\edef\qty{\sankeygetnodeqty{#2}} |
| 3495 |
\pgfmathsetmacro\snk@len{\sankeyqtytolen{\qty}/2} |
| 3496 |
\edef\snk@step{\fpeval{1/\snk@stepoutin}} |
| 3497 |
\edef\snk@laststep{\inteval{\snk@stepoutin-1}} |
| 3498 |
\path[overlay,decorate,decoration={ |
| 3499 |
markings, |
| 3500 |
mark=between positions \snk@step and {\fpeval{1-.5*\snk@step}} |
| 3501 |
step \snk@step with { |
| 3502 |
\edef\snk@outinmidptname{% |
| 3503 |
snk@outinmidpt-% |
| 3504 |
\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}% |
| 3505 |
} |
| 3506 |
\path |
| 3507 |
(0,0) coordinate(\snk@outinmidptname) |
| 3508 |
(0,-\snk@len pt) coordinate (\snk@outinmidptname-r) |
| 3509 |
(0,\snk@len pt) coordinate (\snk@outinmidptname-l) |
| 3510 |
; |
| 3511 |
} |
| 3512 |
}] |
| 3513 |
(#2.center) |
| 3514 |
to[out=\sankeygetnodeorient{#2},in=\sankeygetnodeorient{#3}+180] |
| 3515 |
(#3.center); |
| 3516 |
\foreach \snk@ptnum in {1,...,\snk@laststep}{ |
| 3517 |
\edef\snk@outinmidptname{snk@outinmidpt-\snk@ptnum} |
| 3518 |
\dbp@anglebetween\snk@outinmidptangle% |
| 3519 |
{\snk@outinmidptname-r}{\snk@outinmidptname-l} |
| 3520 |
\sankeynode[debug=false]{% |
| 3521 |
name=\snk@outinmidptname, |
| 3522 |
quantity=\qty, |
| 3523 |
angle=\snk@outinmidptangle-90,% |
| 3524 |
at=\snk@outinmidptname% |
| 3525 |
} |
| 3526 |
} |
| 3527 |
\sankeynode[debug=false]{% |
| 3528 |
name={snk@outinmidpt-0}, |
| 3529 |
quantity=\sankeygetnodeqty{#2}, |
| 3530 |
angle=\sankeygetnodeorient{#2},% |
| 3531 |
at={#2}% |
| 3532 |
} |
| 3533 |
\sankeynode[debug=false]{% |
| 3534 |
name={snk@outinmidpt-\snk@stepoutin}, |
| 3535 |
quantity={\sankeygetnodeqty{#3}}, |
| 3536 |
angle={\sankeygetnodeorient{#3}},% |
| 3537 |
at={#3}% |
| 3538 |
} |
| 3539 |
\path[/sankey/fill,looseness=1] |
| 3540 |
([email protected]) |
| 3541 |
\foreach \snk@curpt |
| 3542 |
[remember=\snk@curpt as \snk@prevpt (initially 0)] |
| 3543 |
in {1,...,\snk@stepoutin}{ |
| 3544 |
to[out=\sankeygetnodeorient{snk@outinmidpt-\snk@prevpt}, |
| 3545 |
in=\sankeygetnodeorient{snk@outinmidpt-\snk@curpt}+180] |
| 3546 |
(snk@outinmidpt-\[email protected]) |
| 3547 |
} |
| 3548 |
-- |
| 3549 |
(snk@outinmidpt-\[email protected]) |
| 3550 |
\foreach \snk@curpt |
| 3551 |
[remember=\snk@curpt as \snk@prevpt (initially \snk@stepoutin)] |
| 3552 |
in {\snk@laststep,...,0}{ |
| 3553 |
to[out=\sankeygetnodeorient{snk@outinmidpt-\snk@prevpt}+180, |
| 3554 |
in=\sankeygetnodeorient{snk@outinmidpt-\snk@curpt}] |
| 3555 |
(snk@outinmidpt-\[email protected]) |
| 3556 |
} |
| 3557 |
-- cycle; |
| 3558 |
\path[/sankey/draw,looseness=1] |
| 3559 |
([email protected]) |
| 3560 |
\foreach \snk@curpt |
| 3561 |
[remember=\snk@curpt as \snk@prevpt (initially 0)] |
| 3562 |
in {1,...,\snk@stepoutin}{ |
| 3563 |
to[out=\sankeygetnodeorient{snk@outinmidpt-\snk@prevpt}, |
| 3564 |
in=\sankeygetnodeorient{snk@outinmidpt-\snk@curpt}+180] |
| 3565 |
(snk@outinmidpt-\[email protected]) |
| 3566 |
} |
| 3567 |
(snk@outinmidpt-\[email protected]) |
| 3568 |
\foreach \snk@curpt |
| 3569 |
[remember=\snk@curpt as \snk@prevpt (initially \snk@stepoutin)] |
| 3570 |
in {\snk@laststep,...,0}{ |
| 3571 |
to[out=\sankeygetnodeorient{snk@outinmidpt-\snk@prevpt}+180, |
| 3572 |
in=\sankeygetnodeorient{snk@outinmidpt-\snk@curpt}] |
| 3573 |
(snk@outinmidpt-\[email protected]) |
| 3574 |
}; |
| 3575 |
\endgroup |
| 3576 |
} |
| 3577 |
% \end{macrocode} |
| 3578 |
% \end{macro} |
| 3579 |
% \begin{macro}{\snk@sankeynodealias} |
| 3580 |
% |
| 3581 |
% The \code{\snk@sankeynodealias} macro clones the Sankey node named |
| 3582 |
% \code{#1} into a Sankey node named \code{#2}. |
| 3583 |
% |
| 3584 |
% \begin{macrocode} |
| 3585 |
\NewDocumentCommand\snk@sankeynodealias{mm}{%name, alias |
| 3586 |
\snk@errorifnotdefined{#1} |
| 3587 |
\path[late options={name=#1,alias=#2}]; |
| 3588 |
\snk@setnodeqty{#2}{\sankeygetnodeqty{#1}} |
| 3589 |
\snk@setnodeorient{#2}{\sankeygetnodeorient{#1}} |
| 3590 |
} |
| 3591 |
% \end{macrocode} |
| 3592 |
% \end{macro} |
| 3593 |
% |
| 3594 |
% \begin{macro}{\snk@sankeynode} |
| 3595 |
% |
| 3596 |
% The \code{\snk@sankeynode} macro creates the new Sankey |
| 3597 |
% node named \code{#2}. |
| 3598 |
% |
| 3599 |
% \begin{macrocode} |
| 3600 |
\NewDocumentCommand\snk@sankeynode{O{}m}{% options, node parameters |
| 3601 |
\begingroup |
| 3602 |
\sankeyset{#1} |
| 3603 |
\sankeyset{node parameters,@initial parameters,/sankey/every node,#2} |
| 3604 |
\snk@makenode{} |
| 3605 |
\snk@makeforkednode{} |
| 3606 |
\iftoggle{sankey node start}{\snk@filldrawstart}{} |
| 3607 |
\iftoggle{sankey node end}{\snk@filldrawend}{} |
| 3608 |
\snk@show@debug{\name} |
| 3609 |
\endgroup |
| 3610 |
} |
| 3611 |
% \end{macrocode} |
| 3612 |
% \end{macro} |
| 3613 |
% |
| 3614 |
% \begin{macro}{\snk@sankeystart} |
| 3615 |
% |
| 3616 |
% The \code{\snk@sankeystart} macro fills and draws a starting lane |
| 3617 |
% attached to the Sankey node named \code{#2}. |
| 3618 |
% |
| 3619 |
% \begin{macrocode} |
| 3620 |
\NewDocumentCommand\snk@sankeystart{O{}m}{% options, name |
| 3621 |
\snk@errorifnotdefined{#2} |
| 3622 |
\begingroup |
| 3623 |
\sankeyset{#1} |
| 3624 |
\edef\name{#2} |
| 3625 |
\edef\orient{\sankeygetnodeorient{#2}} |
| 3626 |
\edef\qty{\sankeygetnodeqty{#2}} |
| 3627 |
\snk@filldrawstart |
| 3628 |
\endgroup |
| 3629 |
} |
| 3630 |
% \end{macrocode} |
| 3631 |
% \end{macro} |
| 3632 |
% |
| 3633 |
% \begin{macro}{\snk@sankeynodestart} |
| 3634 |
% |
| 3635 |
% The \code{\snk@sankeynodestart} macro creates the new Sankey |
| 3636 |
% node named \code{#2} then fills and draws a starting lane |
| 3637 |
% attached to this new Sankey node. |
| 3638 |
% |
| 3639 |
% \begin{macrocode} |
| 3640 |
\NewDocumentCommand\snk@sankeynodestart{O{}m}{% option, node parameters |
| 3641 |
\sankeynode[#1]{start,#2} |
| 3642 |
} |
| 3643 |
% \end{macrocode} |
| 3644 |
% \end{macro} |
| 3645 |
% |
| 3646 |
% \begin{macro}{\snk@sankeyend} |
| 3647 |
% |
| 3648 |
% The \code{\snk@sankeyend} macro fills and draws an ending lane |
| 3649 |
% attached to the Sankey node named \code{#2}. |
| 3650 |
% |
| 3651 |
% \begin{macrocode} |
| 3652 |
\NewDocumentCommand\snk@sankeyend{O{}m}{%options, name |
| 3653 |
\snk@errorifnotdefined{#2} |
| 3654 |
\begingroup |
| 3655 |
\sankeyset{#1} |
| 3656 |
\edef\name{#2} |
| 3657 |
\edef\orient{\sankeygetnodeorient{#2}} |
| 3658 |
\edef\qty{\sankeygetnodeqty{#2}} |
| 3659 |
\snk@filldrawend |
| 3660 |
\endgroup |
| 3661 |
} |
| 3662 |
% \end{macrocode} |
| 3663 |
% \end{macro} |
| 3664 |
% |
| 3665 |
% \begin{macro}{\snk@sankeynodeend} |
| 3666 |
% |
| 3667 |
% The \code{\snk@sankeynodeend} macro creates the new Sankey |
| 3668 |
% node named \code{#2} then fills and draws an ending lane |
| 3669 |
% attached to this new Sankey node. |
| 3670 |
% |
| 3671 |
% \begin{macrocode} |
| 3672 |
\NewDocumentCommand\snk@sankeynodeend{O{}m}{% options, node parameters |
| 3673 |
\sankeynode[#1]{end,#2} |
| 3674 |
} |
| 3675 |
% \end{macrocode} |
| 3676 |
% \end{macro} |
| 3677 |
% |
| 3678 |
% \begin{macro}{\snk@init@move} |
| 3679 |
% |
| 3680 |
% \changes{v3.0.2}{2025/10/10}{Factorization of the node move initialization code} |
| 3681 |
% |
| 3682 |
% The \code{\snk@init@move} macro applies options et clones the |
| 3683 |
% current node before its moving. |
| 3684 |
% |
| 3685 |
% \begin{macrocode} |
| 3686 |
\def\snk@init@move#1#2{% params: options, name |
| 3687 |
\sankeyset{#1} |
| 3688 |
\edef\name{#2} |
| 3689 |
\edef\snk@oldname{#2-old} |
| 3690 |
\sankeynodealias{\name}{\snk@oldname} |
| 3691 |
\edef\qty{\sankeygetnodeqty{\name}} |
| 3692 |
} |
| 3693 |
% \end{macrocode} |
| 3694 |
% \end{macro} |
| 3695 |
% |
| 3696 |
% \begin{macro}{\snk@sankeyadvance} |
| 3697 |
% |
| 3698 |
% The \code{\snk@sankeyadvance} macro moves toward (or backward if |
| 3699 |
% \emph{starred} calls -- \code{#1}) the Sankey node named \code{#3}. |
| 3700 |
% \code{#4} is a distance. The previous position is keeped |
| 3701 |
% by a Sankey node named \code{#3-old}. |
| 3702 |
% |
| 3703 |
% \begin{macrocode} |
| 3704 |
\NewDocumentCommand\snk@sankeyadvance{sO{}mm}{% |
| 3705 |
% params: *(reverse), options, name, distance |
| 3706 |
\snk@errorifnotdefined{#3} |
| 3707 |
\begingroup |
| 3708 |
\snk@init@move{#2}{#3} |
| 3709 |
\IfBooleanTF{#1}{ |
| 3710 |
% move backward |
| 3711 |
\sankeynode{ |
| 3712 |
at={$(\[email protected])!#4!90:(\[email protected])$}, |
| 3713 |
angle=\sankeygetnodeorient{\snk@oldname}, |
| 3714 |
quantity=\sankeygetnodeqty{\snk@oldname}, |
| 3715 |
name=\name, |
| 3716 |
} |
| 3717 |
\path[/sankey/fill] |
| 3718 |
(\name.left) -- (\[email protected]) |
| 3719 |
-- (\[email protected]) -- (\name.right) -- cycle; |
| 3720 |
\path[/sankey/draw] |
| 3721 |
(\name.left) -- (\[email protected]) |
| 3722 |
(\[email protected]) -- (\name.right); |
| 3723 |
}{ |
| 3724 |
% move forward |
| 3725 |
\sankeynode{ |
| 3726 |
at={$(\[email protected])!#4!-90:(\[email protected])$}, |
| 3727 |
angle=\sankeygetnodeorient{\snk@oldname}, |
| 3728 |
quantity=\sankeygetnodeqty{\snk@oldname}, |
| 3729 |
name=\name, |
| 3730 |
} |
| 3731 |
\path[/sankey/fill] |
| 3732 |
(\[email protected]) -- (\name.left) |
| 3733 |
-- (\name.right) -- (\[email protected]) -- cycle; |
| 3734 |
\path[/sankey/draw] |
| 3735 |
(\[email protected]) -- (\name.left) |
| 3736 |
(\name.right) -- (\[email protected]); |
| 3737 |
} |
| 3738 |
\snk@show@debug{\name} |
| 3739 |
\endgroup |
| 3740 |
} |
| 3741 |
% \end{macrocode} |
| 3742 |
% \end{macro} |
| 3743 |
% \begin{macro}{\snk@sankeyturnright} |
| 3744 |
% |
| 3745 |
% \changes{v3.0}{2021/03/14}{New macro} |
| 3746 |
% |
| 3747 |
% The \code{sankeyturnright} macro moves forward the Sankey node named |
| 3748 |
% \code{#3} by turning right. The angle is \code{#4} (the starred |
| 3749 |
% version uses the opposite of \code{#4}). If the angle is |
| 3750 |
% \emph{negative}, the macro calls the \code{\sankeyturnrightbackward} |
| 3751 |
% macro to move backward else the macro fills/draws the lane between |
| 3752 |
% the previous position and the new position. The previous position is |
| 3753 |
% keeped by a Sankey node named \code{#3-old}. |
| 3754 |
% |
| 3755 |
% \begin{macrocode} |
| 3756 |
\NewDocumentCommand\snk@sankeyturnright{sO{}mm}{ |
| 3757 |
% *(reverse), options, name, angle |
| 3758 |
\snk@errorifnotdefined{#3} |
| 3759 |
\begingroup |
| 3760 |
\IfBooleanTF{#1} |
| 3761 |
{\edef\snk@angle{\fpeval{-1*#4}}} |
| 3762 |
{\edef\snk@angle{\fpeval{1*#4}}} |
| 3763 |
\edef\snk@anglesign{\fpeval{sign(\snk@angle)}} |
| 3764 |
\ifnumgreater{\snk@anglesign}{-1}{ |
| 3765 |
\snk@init@move{#2}{#3} |
| 3766 |
\edef\orient{\snk@normalize@angle{\sankeygetnodeorient{\name}-\snk@angle}} |
| 3767 |
\snk@getpos\snk@c{$(\name.right)!-\snk@minradius!(\name.left)$} |
| 3768 |
\snk@getpos\pos{$(\snk@c)!1!-\snk@angle:(\name.center)$} |
| 3769 |
\snk@makenode{} |
| 3770 |
% fill the region |
| 3771 |
\path[/sankey/fill] let |
| 3772 |
\p1=(\[email protected]),\p2=(\[email protected]), |
| 3773 |
\p3=(\name.left),\p4=(\name.right), |
| 3774 |
\n1={\sankeyqtytolen{\qty}}, |
| 3775 |
\n{maxr}={\snk@minradius+\n1}, |
| 3776 |
\n{minr}={\snk@minradius} |
| 3777 |
in |
| 3778 |
(\p1) arc(\orient+\snk@angle+90:\orient+90:\n{maxr}) -- (\p3) -- |
| 3779 |
(\p4) arc(\orient+90:\orient+\snk@angle+90:\n{minr}) -- (\p2) -- cycle; |
| 3780 |
% draw left and right borders |
| 3781 |
\path[/sankey/draw] let |
| 3782 |
\p1=(\[email protected]),\p2=(\[email protected]), |
| 3783 |
\p3=(\name.left),\p4=(\name.right), |
| 3784 |
\n1={\sankeyqtytolen{\qty}}, |
| 3785 |
\n{maxr}={\snk@minradius+\n1}, |
| 3786 |
\n{minr}={\snk@minradius} |
| 3787 |
in |
| 3788 |
(\p1) arc(\orient+\snk@angle+90:\orient+90:\n{maxr}) |
| 3789 |
(\p4) arc(\orient+90:\orient+\snk@angle+90:\n{minr}); |
| 3790 |
\snk@show@debug{\name} |
| 3791 |
}{ |
| 3792 |
\sankeyturnrightbackward[#2]{#3}{-1*\snk@angle} |
| 3793 |
} |
| 3794 |
\endgroup |
| 3795 |
} |
| 3796 |
% \end{macrocode} |
| 3797 |
% \end{macro} |
| 3798 |
% |
| 3799 |
% \begin{macro}{\snk@sankeyturnrightbackward} |
| 3800 |
% |
| 3801 |
% \changes{v3.0}{2021/03/14}{New macro} |
| 3802 |
% |
| 3803 |
% The \code{\snk@sankeyturnrightbackward} macro moves backward the |
| 3804 |
% Sankey node named \code{#3} by turning right. The angle is \code{#4} |
| 3805 |
% (the starred version uses the opposite of \code{#4}). If the angle |
| 3806 |
% is \emph{negative}, the macro calls the \code{\sankeyturnright} |
| 3807 |
% macro to move forward else the macro fills/draws the lane between |
| 3808 |
% the previous position and the new position. The previous position is |
| 3809 |
% keeped by a Sankey node named \code{#3-old}. |
| 3810 |
% |
| 3811 |
% \begin{macrocode} |
| 3812 |
\NewDocumentCommand\snk@sankeyturnrightbackward{sO{}mm}{ |
| 3813 |
% *(reverse), options, name, angle |
| 3814 |
\snk@errorifnotdefined{#3} |
| 3815 |
\begingroup |
| 3816 |
\IfBooleanTF{#1} |
| 3817 |
{\edef\snk@angle{\fpeval{-1*#4}}} |
| 3818 |
{\edef\snk@angle{\fpeval{1*#4}}} |
| 3819 |
\edef\snk@anglesign{\fpeval{sign(\snk@angle)}} |
| 3820 |
\ifnumgreater{\snk@anglesign}{-1}{ |
| 3821 |
\snk@init@move{#2}{#3} |
| 3822 |
\edef\orient{\snk@normalize@angle{\sankeygetnodeorient{\name}+\snk@angle}} |
| 3823 |
\snk@getpos\snk@c{$(\name.right)!-\snk@minradius!(\name.left)$} |
| 3824 |
\snk@getpos\pos{$(\snk@c)!1!\snk@angle:(\name.center)$} |
| 3825 |
\snk@makenode{} |
| 3826 |
% fill the region |
| 3827 |
\path[/sankey/fill] let |
| 3828 |
\p1=(\name.left),\p2=(\name.right), |
| 3829 |
\p3=(\[email protected]),\p4=(\[email protected]), |
| 3830 |
\n1={\sankeyqtytolen{\qty}}, |
| 3831 |
\n{maxr}={\snk@minradius+\n1}, \n{minr}={\snk@minradius} |
| 3832 |
in |
| 3833 |
(\p1) arc(\orient+90:\orient-\snk@angle+90:\n{maxr}) -- (\p3) -- |
| 3834 |
(\p4) arc(\orient-\snk@angle+90:\orient+90:\n{minr}) -- (\p2) -- cycle; |
| 3835 |
% draw left and right borders |
| 3836 |
\path[/sankey/draw] let |
| 3837 |
\p1=(\name.left),\p2=(\name.right), |
| 3838 |
\p3=(\[email protected]),\p4=(\[email protected]), |
| 3839 |
\n1={\sankeyqtytolen{\qty}}, |
| 3840 |
\n{maxr}={\snk@minradius+\n1}, \n{minr}={\snk@minradius} |
| 3841 |
in |
| 3842 |
(\p1) arc(\orient+90:\orient-\snk@angle+90:\n{maxr}) |
| 3843 |
(\p4) arc(\orient-\snk@angle+90:\orient+90:\n{minr}); |
| 3844 |
\snk@show@debug{\name} |
| 3845 |
}{ |
| 3846 |
\sankeyturnright[#2]{#3}{-1*\snk@angle} |
| 3847 |
} |
| 3848 |
\endgroup |
| 3849 |
} |
| 3850 |
% \end{macrocode} |
| 3851 |
% \end{macro} |
| 3852 |
% \begin{macro}{\snk@sankeyturnleft} |
| 3853 |
% |
| 3854 |
% \changes{v3.0}{2021/03/14}{New macro} |
| 3855 |
% |
| 3856 |
% The \code{\snk@sankeyturnleft} macro moves forward the Sankey node |
| 3857 |
% named \code{#3} by turning left. The angle is \code{#4} (the starred |
| 3858 |
% version uses the opposite of \code{#4}). If the angle is |
| 3859 |
% \emph{negative}, the macro calls the \code{\sankeyturnleftbackward} |
| 3860 |
% macro to move backward else the macro fills/draws the lane between |
| 3861 |
% the previous position and the new position. The previous position is |
| 3862 |
% keeped by a Sankey node named \code{#3-old}. |
| 3863 |
% |
| 3864 |
% \begin{macrocode} |
| 3865 |
\NewDocumentCommand\snk@sankeyturnleft{sO{}mm}{ |
| 3866 |
% *(reverse), options, name, angle |
| 3867 |
\snk@errorifnotdefined{#3} |
| 3868 |
\begingroup |
| 3869 |
\IfBooleanTF{#1} |
| 3870 |
{\edef\snk@angle{\fpeval{-1*#4}}} |
| 3871 |
{\edef\snk@angle{\fpeval{1*#4}}} |
| 3872 |
\edef\snk@anglesign{\fpeval{sign(\snk@angle)}} |
| 3873 |
\ifnumgreater{\snk@anglesign}{-1}{ |
| 3874 |
\snk@init@move{#2}{#3} |
| 3875 |
\edef\orient{\snk@normalize@angle{\sankeygetnodeorient{\name}+\snk@angle}} |
| 3876 |
\snk@getpos\snk@c{$(\name.left)!-\snk@minradius!(\name.right)$} |
| 3877 |
\snk@getpos\pos{$(\snk@c)!1!\snk@angle:(\name.center)$} |
| 3878 |
\snk@makenode{} |
| 3879 |
% fill the region |
| 3880 |
\path[/sankey/fill] let |
| 3881 |
\p1=(\[email protected]),\p2=(\[email protected]), |
| 3882 |
\p3=(\name.left),\p4=(\name.right), |
| 3883 |
\n1={\sankeyqtytolen{\qty}}, |
| 3884 |
\n{maxr}={\snk@minradius+\n1}, \n{minr}={\snk@minradius} |
| 3885 |
in |
| 3886 |
(\p1) arc(\orient-\snk@angle-90:\orient-90:\n{minr}) -- (\p3) -- |
| 3887 |
(\p4) arc(\orient-90:\orient-\snk@angle-90:\n{maxr}) -- (\p2) -- cycle; |
| 3888 |
% draw left and right borders |
| 3889 |
\path[/sankey/draw] let |
| 3890 |
\p1=(\[email protected]),\p2=(\[email protected]), |
| 3891 |
\p3=(\name.left),\p4=(\name.right), |
| 3892 |
\n1={\sankeyqtytolen{\qty}}, |
| 3893 |
\n{maxr}={\snk@minradius+\n1}, \n{minr}={\snk@minradius} |
| 3894 |
in |
| 3895 |
(\p1) arc(\orient-\snk@angle-90:\orient-90:\n{minr}) |
| 3896 |
(\p4) arc(\orient-90:\orient-\snk@angle-90:\n{maxr}); |
| 3897 |
\snk@show@debug{\name} |
| 3898 |
}{ |
| 3899 |
\sankeyturnleftbackward[#2]{#3}{-1*\snk@angle} |
| 3900 |
} |
| 3901 |
\endgroup |
| 3902 |
} |
| 3903 |
% \end{macrocode} |
| 3904 |
% \end{macro} |
| 3905 |
% \begin{macro}{\snk@sankeyturnleftbackward} |
| 3906 |
% |
| 3907 |
% \changes{v3.0}{2021/03/14}{New macro} |
| 3908 |
% |
| 3909 |
% The \code{\snk@sankeyturnleftbackward} macro moves backward the |
| 3910 |
% Sankey node named \code{#3} by turning left. The angle is \code{#4} |
| 3911 |
% (the starred version uses the opposite of \code{#4}). If the angle |
| 3912 |
% is \emph{negative}, the macro calls the \code{\sankeyturnleft} macro |
| 3913 |
% to move forward else the macro fills/draws the lane between the |
| 3914 |
% previous position and the new position. The previous position is |
| 3915 |
% keeped by a Sankey node named \code{#3-old}. |
| 3916 |
% |
| 3917 |
% \begin{macrocode} |
| 3918 |
\NewDocumentCommand\snk@sankeyturnleftbackward{sO{}mm}{ |
| 3919 |
% *(reverse), options, name, angle |
| 3920 |
\snk@errorifnotdefined{#3} |
| 3921 |
\begingroup |
| 3922 |
\IfBooleanTF{#1} |
| 3923 |
{\edef\snk@angle{\fpeval{-1*#4}}} |
| 3924 |
{\edef\snk@angle{\fpeval{1*#4}}} |
| 3925 |
\edef\snk@anglesign{\fpeval{sign(\snk@angle)}} |
| 3926 |
\ifnumgreater{\snk@anglesign}{-1}{ |
| 3927 |
\snk@init@move{#2}{#3} |
| 3928 |
\edef\orient{\snk@normalize@angle{\sankeygetnodeorient{\name}-\snk@angle}} |
| 3929 |
\snk@getpos\snk@c{$(\name.left)!-\snk@minradius!(\name.right)$} |
| 3930 |
\snk@getpos\pos{$(\snk@c)!1!-\snk@angle:(\name.center)$} |
| 3931 |
\snk@makenode{} |
| 3932 |
% fill the region |
| 3933 |
\path[/sankey/fill] let |
| 3934 |
\p1=(\name.left),\p2=(\name.right), |
| 3935 |
\p3=(\[email protected]),\p4=(\[email protected]), |
| 3936 |
\n1={\sankeyqtytolen{\qty}}, |
| 3937 |
\n{maxr}={\snk@minradius+\n1}, \n{minr}={\snk@minradius} |
| 3938 |
in |
| 3939 |
(\p1) arc(\orient-90:\orient+\snk@angle-90:\n{minr}) -- (\p3) -- |
| 3940 |
(\p4) arc(\orient+\snk@angle-90:\orient-90:\n{maxr}) -- (\p2) -- cycle; |
| 3941 |
% draw left and right borders |
| 3942 |
\path[/sankey/draw] let |
| 3943 |
\p1=(\name.left),\p2=(\name.right), |
| 3944 |
\p3=(\[email protected]),\p4=(\[email protected]), |
| 3945 |
\n1={\sankeyqtytolen{\qty}}, |
| 3946 |
\n{maxr}={\snk@minradius+\n1}, \n{minr}={\snk@minradius} |
| 3947 |
in |
| 3948 |
(\p1) arc(\orient-90:\orient+\snk@angle-90:\n{minr}) |
| 3949 |
(\p4) arc(\orient+\snk@angle-90:\orient-90:\n{maxr}); |
| 3950 |
\snk@show@debug{\name} |
| 3951 |
}{ |
| 3952 |
\sankeyturnleft[#2]{#3}{-1*\snk@angle} |
| 3953 |
} |
| 3954 |
\endgroup |
| 3955 |
} |
| 3956 |
% \end{macrocode} |
| 3957 |
% \end{macro} |
| 3958 |
% \begin{macro}{\snk@sankeyturn} |
| 3959 |
% |
| 3960 |
% \changes{v3.0}{2021/03/14}{Simplification by using new \emph{turn} macros} |
| 3961 |
% |
| 3962 |
% The \code{\snk@sankeyturn} macro moves toward (or backward if |
| 3963 |
% \emph{starred} calls -- \code{#1}) the Sankey node named \code{#3} |
| 3964 |
% by turning left (angle \code{#4} is positive) or right (angle |
| 3965 |
% \code{#4} is negative). The previous position is keeped by a Sankey |
| 3966 |
% node named \code{#3-old}. |
| 3967 |
% |
| 3968 |
% \begin{macrocode} |
| 3969 |
\NewDocumentCommand\snk@sankeyturn{sO{}mm}{% |
| 3970 |
% *(reverse), options, name, angle |
| 3971 |
\snk@errorifnotdefined{#3} |
| 3972 |
\begingroup |
| 3973 |
\edef\snk@anglesign{\fpeval{sign(#4)}} |
| 3974 |
\IfBooleanTF{#1}{ |
| 3975 |
\ifnumgreater{\snk@anglesign}{-1} |
| 3976 |
{\sankeyturnleftbackward[#2]{#3}{#4}} |
| 3977 |
{\sankeyturnrightbackward[#2]{#3}{-1*#4}} |
| 3978 |
}{ |
| 3979 |
\ifnumgreater{\snk@anglesign}{-1} |
| 3980 |
{\sankeyturnleft[#2]{#3}{#4}} |
| 3981 |
{\sankeyturnright[#2]{#3}{-1*#4}} |
| 3982 |
} |
| 3983 |
\endgroup |
| 3984 |
} |
| 3985 |
% \end{macrocode} |
| 3986 |
% \end{macro} |
| 3987 |
% \begin{macro}{\snk@sankeyfork} |
| 3988 |
% |
| 3989 |
% The \code{\snk@sankeyfork} macro forks the Sankey node named |
| 3990 |
% \code{#2} to the list of subnodes given by \code{#3}. |
| 3991 |
% The subnodes are cloned to take into account |
| 3992 |
% the \code{debug} option. |
| 3993 |
% |
| 3994 |
% \begin{macrocode} |
| 3995 |
\NewDocumentCommand\snk@sankeyfork{O{}mm}{%options, name, list of forks |
| 3996 |
\snk@errorifnotdefined{#2} |
| 3997 |
\begingroup |
| 3998 |
\sankeyset{#1} |
| 3999 |
\sankeynode[debug=false]{as={#2},forked={#3}} |
| 4000 |
\foreach \qty/\snk@subnodename in {#3}{\sankeynode{as={\snk@subnodename}}} |
| 4001 |
\endgroup |
| 4002 |
} |
| 4003 |
% \end{macrocode} |
| 4004 |
% \end{macro} |
| 4005 |
% \begin{macro}{\snk@sankeyqtytolen} |
| 4006 |
% |
| 4007 |
% The \code{\snk@sankeyqtytolen} macro converts quantity to length |
| 4008 |
% using \code{\fpeval} and the ratio determined by |
| 4009 |
% \code{\snk@totalqty} and \code{\snk@totallen}. |
| 4010 |
% |
| 4011 |
% \begin{macrocode} |
| 4012 |
\NewExpandableDocumentCommand\snk@sankeyqtytolen{m}{% |
| 4013 |
\fpeval{(#1)/\snk@totalqty*\snk@totallen}% |
| 4014 |
} |
| 4015 |
% \end{macrocode} |
| 4016 |
% \end{macro} |
| 4017 |
% |
| 4018 |
%^^A % ------------------------------------------------------------ |
| 4019 |
% \subsection{The \protect\ttintitle{sankeydiagram} environment} |
| 4020 |
%^^A % ------------------------------------------------------------ |
| 4021 |
% |
| 4022 |
% |
| 4023 |
% \begin{environment}{sankeydiagram} |
| 4024 |
% |
| 4025 |
% \changes{v3.0.2}{2025/01/10}{Simplification of the environment by copying internal macros} |
| 4026 |
% |
| 4027 |
% The \code{sankeydiagram} environment allows the creation of Sankey |
| 4028 |
% diagrams. |
| 4029 |
% |
| 4030 |
% \DescribeMacro{\sankeyadvance}% |
| 4031 |
% \DescribeMacro{\sankeydubins}% |
| 4032 |
% \DescribeMacro{\sankeyend}% |
| 4033 |
% \DescribeMacro{\sankeyfork}% |
| 4034 |
% \DescribeMacro{\sankeynodealias}% |
| 4035 |
% \DescribeMacro{\sankeynodeend}% |
| 4036 |
% \DescribeMacro{\sankeynodestart}% |
| 4037 |
% \DescribeMacro{\sankeynode}% |
| 4038 |
% \DescribeMacro{\sankeyoutin}% |
| 4039 |
% \DescribeMacro{\sankeyqtytolen}% |
| 4040 |
% \DescribeMacro{\sankeystart}% |
| 4041 |
% \DescribeMacro{\sankeyturnleftbackward}% |
| 4042 |
% \DescribeMacro{\sankeyturnleft}% |
| 4043 |
% \DescribeMacro{\sankeyturnrightbackward}% |
| 4044 |
% \DescribeMacro{\sankeyturnright}% |
| 4045 |
% \DescribeMacro{\sankeyturn}% |
| 4046 |
% It defines locally all the macros used by a Sankey diagram. |
| 4047 |
% |
| 4048 |
% Then it applies the \code{@initial options} and \code{every diagram} |
| 4049 |
% styles (in this order) and applies all the keys provided in its |
| 4050 |
% optional argument. |
| 4051 |
% |
| 4052 |
% \begin{macrocode} |
| 4053 |
\NewDocumentEnvironment{sankeydiagram}{O{}}{ |
| 4054 |
\NewCommandCopy{\sankeyadvance}{\snk@sankeyadvance} |
| 4055 |
\NewCommandCopy{\sankeydubins}{\snk@sankeydubins} |
| 4056 |
\NewCommandCopy{\sankeyend}{\snk@sankeyend} |
| 4057 |
\NewCommandCopy{\sankeyfork}{\snk@sankeyfork} |
| 4058 |
\NewCommandCopy{\sankeynodealias}{\snk@sankeynodealias} |
| 4059 |
\NewCommandCopy{\sankeynodeend}{\snk@sankeynodeend} |
| 4060 |
\NewCommandCopy{\sankeynodestart}{\snk@sankeynodestart} |
| 4061 |
\NewCommandCopy{\sankeynode}{\snk@sankeynode} |
| 4062 |
\NewCommandCopy{\sankeyoutin}{\snk@sankeyoutin} |
| 4063 |
\NewCommandCopy{\sankeyqtytolen}{\snk@sankeyqtytolen} |
| 4064 |
\NewCommandCopy{\sankeystart}{\snk@sankeystart} |
| 4065 |
\NewCommandCopy{\sankeyturnleftbackward}{\snk@sankeyturnleftbackward} |
| 4066 |
\NewCommandCopy{\sankeyturnleft}{\snk@sankeyturnleft} |
| 4067 |
\NewCommandCopy{\sankeyturnrightbackward}{\snk@sankeyturnrightbackward} |
| 4068 |
\NewCommandCopy{\sankeyturnright}{\snk@sankeyturnright} |
| 4069 |
\NewCommandCopy{\sankeyturn}{\snk@sankeyturn} |
| 4070 |
\sankeyset{ |
| 4071 |
@initial options, |
| 4072 |
every diagram, |
| 4073 |
% user values |
| 4074 |
#1} |
| 4075 |
} |
| 4076 |
{} % empty but mandatory ! :-) |
| 4077 |
% \end{macrocode} |
| 4078 |
% \end{environment} |
| 4079 |
% |
| 4080 |
%^^A % ------------------------------------------------------------ |
| 4081 |
% \subsection{Predefined start and end styles} |
| 4082 |
%^^A % ------------------------------------------------------------ |
| 4083 |
% |
| 4084 |
% The \code{none} style. |
| 4085 |
% |
| 4086 |
% \begin{macrocode} |
| 4087 |
\sankeyset{ |
| 4088 |
new start style={none}{}{}, |
| 4089 |
new end style={none}{}{}, |
| 4090 |
} |
| 4091 |
% \end{macrocode} |
| 4092 |
% |
| 4093 |
% The \code{simple} style. |
| 4094 |
% |
| 4095 |
% \begin{macrocode} |
| 4096 |
\sankeyset{ |
| 4097 |
new start style={simple}{ |
| 4098 |
(\name.left) -- ([xshift=-.5\pgflinewidth]\name.left) |
| 4099 |
-- ([xshift=-.5\pgflinewidth]\name.right) -- (\name.right) -- cycle |
| 4100 |
}{ |
| 4101 |
(\name.left) -- ([xshift=-.5\pgflinewidth]\name.left) |
| 4102 |
-- ([xshift=-.5\pgflinewidth]\name.right) -- (\name.right) |
| 4103 |
}, |
| 4104 |
new end style={simple}{ |
| 4105 |
(\name.left) -- ([xshift=2mm]\name.center) |
| 4106 |
-- (\name.right) -- cycle |
| 4107 |
}{ |
| 4108 |
(\name.left) -- ([xshift=2mm]\name.center) -- (\name.right) |
| 4109 |
}, |
| 4110 |
} |
| 4111 |
% \end{macrocode} |
| 4112 |
% |
| 4113 |
% The \code{arrow} style. |
| 4114 |
% |
| 4115 |
% \begin{macrocode} |
| 4116 |
\sankeyset{ |
| 4117 |
new start style={arrow}{ |
| 4118 |
(\name.left) -- ++(-10pt,0) -- ([xshift=-10pt/6]\name.center) |
| 4119 |
-- ([xshift=-10pt]\name.right) -- (\name.right) -- cycle |
| 4120 |
}{ |
| 4121 |
(\name.left) -- ++(-10pt,0) -- ([xshift=-10pt/6]\name.center) |
| 4122 |
-- ([xshift=-10pt]\name.right) -- (\name.right) |
| 4123 |
}, |
| 4124 |
new end style={arrow}{ |
| 4125 |
(\name.left) -- ([yshift=1mm]\name.left) |
| 4126 |
-- ([xshift=10pt]\name.center) -- ([yshift=-1mm]\name.right) |
| 4127 |
-- (\name.right) -- cycle |
| 4128 |
}{ |
| 4129 |
(\name.left) -- ([yshift=1mm]\name.left) |
| 4130 |
-- ([xshift=10pt]\name.center) -- ([yshift=-1mm]\name.right) |
| 4131 |
-- (\name.right) |
| 4132 |
}, |
| 4133 |
} |
| 4134 |
% \end{macrocode} |
| 4135 |
% \iffalse |
| 4136 |
%</sankey> |
| 4137 |
% \fi |
| 4138 |
% |
| 4139 |
%^^A % ------------------------------------------------------------ |
| 4140 |
% \section{\ttintitle{tikzlibrarydubins.code.tex}} |
| 4141 |
%^^A % ------------------------------------------------------------ |
| 4142 |
% |
| 4143 |
% Not yet documented nor commented... |
| 4144 |
% |
| 4145 |
% \iffalse |
| 4146 |
%<*tikzlibrarydubins.code.tex> |
| 4147 |
% \fi |
| 4148 |
% \begin{macro}{\tikzlibrarydubins@version} |
| 4149 |
% \begin{macro}{\tikzlibrarydubins@date} |
| 4150 |
% \begin{macrocode} |
| 4151 |
\def\tikzlibrarydubins@version{v3.0.2} |
| 4152 |
\def\tikzlibrarydubins@date{2025/01/10} |
| 4153 |
% \end{macrocode} |
| 4154 |
% \end{macro} |
| 4155 |
% \end{macro} |
| 4156 |
% |
| 4157 |
% \begin{macrocode} |
| 4158 |
\usetikzlibrary{calc} |
| 4159 |
\RequirePackage{etoolbox} |
| 4160 |
\RequirePackage{xfp} |
| 4161 |
|
| 4162 |
\newbool{dubinspathreverse} |
| 4163 |
% \end{macrocode} |
| 4164 |
% |
| 4165 |
% \begin{macro}{\ifpgfmathcond} |
| 4166 |
% \begin{macrocode} |
| 4167 |
\def\ifpgfmathcond#1{% |
| 4168 |
\pgfmathparse{(#1)?1:0}% |
| 4169 |
\ifnumequal{\pgfmathresult}{1}% |
| 4170 |
} |
| 4171 |
% \end{macrocode} |
| 4172 |
% \end{macro} |
| 4173 |
% |
| 4174 |
% \begin{macro}{\dbp@getxy} |
| 4175 |
% \begin{macrocode} |
| 4176 |
\def\dbp@getxy#1#2#3{% |
| 4177 |
\tikz@scan@one@point\pgfutil@firstofone(#3)\relax% |
| 4178 |
\edef#1{\the\pgf@x}% |
| 4179 |
\edef#2{\the\pgf@y}% |
| 4180 |
} |
| 4181 |
% \end{macrocode} |
| 4182 |
% \end{macro} |
| 4183 |
% |
| 4184 |
% \begin{macro}{\dbp@anglebetween} |
| 4185 |
% \begin{macrocode} |
| 4186 |
\def\dbp@anglebetween#1#2#3{%macro, s, t |
| 4187 |
\dbp@getxy\dbp@ax\dbp@ay{#2} |
| 4188 |
\dbp@getxy\dbp@bx\dbp@by{#3} |
| 4189 |
\pgfmathsetmacro#1{atan2(\dbp@by-\dbp@ay,\dbp@bx-\dbp@ax)} |
| 4190 |
} |
| 4191 |
% \end{macrocode} |
| 4192 |
% \end{macro} |
| 4193 |
% |
| 4194 |
% \begin{macro}{\dbp@distancebetween} |
| 4195 |
% \begin{macrocode} |
| 4196 |
\def\dbp@distancebetween#1#2#3{%macro, s, t |
| 4197 |
\dbp@getxy\dbp@ax\dbp@ay{#2} |
| 4198 |
\dbp@getxy\dbp@bx\dbp@by{#3} |
| 4199 |
\edef#1{\fpeval{sqrt(% |
| 4200 |
(\dbp@bx-\dbp@ax)*(\dbp@bx-\dbp@ax)% |
| 4201 |
+(\dbp@by-\dbp@ay)*(\dbp@by-\dbp@ay)% |
| 4202 |
)}}% |
| 4203 |
} |
| 4204 |
% \end{macrocode} |
| 4205 |
% \end{macro} |
| 4206 |
% \begin{macro}{\dbp@rsr} |
| 4207 |
% \begin{macrocode} |
| 4208 |
\newcommand\dbp@rsr{% s, sa, t, ta, as, len, at, r |
| 4209 |
let |
| 4210 |
\p{tr}=([shift={(\dbp@angb-90:\dbp@radius pt)}]\dbp@b), |
| 4211 |
\n1={\dbp@anga+90}, |
| 4212 |
\n2={\dbp@angb+90}, |
| 4213 |
\n3={\n2+\dbp@lastangle} |
| 4214 |
in |
| 4215 |
arc(\n1:\n1-\dbp@firstangle:\dbp@rradius pt) |
| 4216 |
-- ([shift={(\p{tr})}]\n3:\dbp@rradius pt) |
| 4217 |
arc(\n3:\n2:\dbp@rradius pt) |
| 4218 |
} |
| 4219 |
% \end{macrocode} |
| 4220 |
% \end{macro} |
| 4221 |
% |
| 4222 |
% \begin{macro}{\dbp@lsl} |
| 4223 |
% \begin{macrocode} |
| 4224 |
\newcommand\dbp@lsl{% s, sa, t, ta, as, len, at, r |
| 4225 |
let |
| 4226 |
\p{tl}=([shift={(\dbp@angb+90:\dbp@radius pt)}]\dbp@b), |
| 4227 |
\n1={\dbp@anga-90},\n2={\n1+\dbp@firstangle}, |
| 4228 |
\n3={\dbp@angb-90},\n4={\n3-\dbp@lastangle} |
| 4229 |
in |
| 4230 |
arc(\n1:\n2:\dbp@lradius pt) |
| 4231 |
-- ([shift={(\p{tl})}]\n4:\dbp@lradius pt) |
| 4232 |
arc(\n4:\n3:\dbp@lradius pt) |
| 4233 |
} |
| 4234 |
% \end{macrocode} |
| 4235 |
% \end{macro} |
| 4236 |
% |
| 4237 |
% \begin{macro}{\dbp@rsl} |
| 4238 |
% \begin{macrocode} |
| 4239 |
\newcommand\dbp@rsl{% s, sa, t, ta, as, len, at, r |
| 4240 |
let |
| 4241 |
\p{tl}=([shift={(\dbp@angb+90:\dbp@radius pt)}]\dbp@b), |
| 4242 |
\n1={\dbp@anga+90},\n2={\n1-\dbp@firstangle}, |
| 4243 |
\n3={\dbp@angb-90},\n4={\n3-\dbp@lastangle} |
| 4244 |
in |
| 4245 |
arc(\n1:\n2:\dbp@rradius pt) |
| 4246 |
-- ([shift={(\p{tl})}]\n4:\dbp@lradius pt) |
| 4247 |
arc(\n4:\n3:\dbp@lradius pt) |
| 4248 |
} |
| 4249 |
% \end{macrocode} |
| 4250 |
% \end{macro} |
| 4251 |
% |
| 4252 |
% \begin{macro}{\dbp@lsr} |
| 4253 |
% \begin{macrocode} |
| 4254 |
\newcommand\dbp@lsr{% s, sa, t, ta, as, len, at, r |
| 4255 |
let |
| 4256 |
\p{tr}=([shift={(\dbp@angb-90:\dbp@radius pt)}]\dbp@b), |
| 4257 |
\n1={\dbp@anga-90},\n2={\n1+\dbp@firstangle}, |
| 4258 |
\n3={\dbp@angb+90},\n4={\n3+\dbp@lastangle} |
| 4259 |
in |
| 4260 |
arc(\n1:\n2:\dbp@lradius pt) |
| 4261 |
-- ([shift={(\p{tr})}]\n4:\dbp@rradius pt) |
| 4262 |
arc(\n4:\n3:\dbp@rradius pt) |
| 4263 |
} |
| 4264 |
% \end{macrocode} |
| 4265 |
% \end{macro} |
| 4266 |
% |
| 4267 |
% \begin{macro}{\dbp@lrl} |
| 4268 |
% \begin{macrocode} |
| 4269 |
\newcommand\dbp@lrl{% s, sa, t, ta, as, ai, at, r |
| 4270 |
let |
| 4271 |
\n1={\dbp@anga-90},\n2={\n1+\dbp@firstangle}, |
| 4272 |
\n3={\dbp@angb-90},\n4={\n3-\dbp@lastangle} |
| 4273 |
in |
| 4274 |
arc(\n1:\n2:\dbp@lradius pt) |
| 4275 |
arc(\n2+180:\n2+180-\dbp@midparam:\dbp@rradius pt) |
| 4276 |
arc(\n4:\n3:\dbp@lradius pt) |
| 4277 |
} |
| 4278 |
% \end{macrocode} |
| 4279 |
% \end{macro} |
| 4280 |
% |
| 4281 |
% \begin{macro}{\dbp@rlr} |
| 4282 |
% \begin{macrocode} |
| 4283 |
\newcommand\dbp@rlr{% s, sa, t, ta, as, ai, at, r |
| 4284 |
let |
| 4285 |
\n1={\dbp@anga+90},\n2={\n1-\dbp@firstangle}, |
| 4286 |
\n3={\dbp@angb+90},\n4={\n3+\dbp@lastangle} |
| 4287 |
in |
| 4288 |
arc(\n1:\n2:\dbp@rradius pt) |
| 4289 |
arc(\n2+180:\n2+180+\dbp@midparam:\dbp@lradius pt) |
| 4290 |
arc(\n4:\n3:\dbp@rradius pt) |
| 4291 |
} |
| 4292 |
% \end{macrocode} |
| 4293 |
% \end{macro} |
| 4294 |
% |
| 4295 |
% \begin{macro}{\dbp@rev@lsl} |
| 4296 |
% \begin{macrocode} |
| 4297 |
\newcommand\dbp@rev@lsl{\dbp@rsr} |
| 4298 |
% \end{macrocode} |
| 4299 |
% \end{macro} |
| 4300 |
% |
| 4301 |
% \begin{macro}{\dbp@rev@rsr} |
| 4302 |
% \begin{macrocode} |
| 4303 |
\newcommand\dbp@rev@rsr{\dbp@lsl} |
| 4304 |
% \end{macrocode} |
| 4305 |
% \end{macro} |
| 4306 |
% |
| 4307 |
% \begin{macro}{\dbp@rev@lsr} |
| 4308 |
% \begin{macrocode} |
| 4309 |
\newcommand\dbp@rev@lsr{\dbp@lsr} |
| 4310 |
% \end{macrocode} |
| 4311 |
% \end{macro} |
| 4312 |
% |
| 4313 |
% \begin{macro}{\dbp@rev@rsl} |
| 4314 |
% \begin{macrocode} |
| 4315 |
\newcommand\dbp@rev@rsl{\dbp@rsl} |
| 4316 |
% \end{macrocode} |
| 4317 |
% \end{macro} |
| 4318 |
% |
| 4319 |
% \begin{macro}{\dbp@rev@lrl} |
| 4320 |
% \begin{macrocode} |
| 4321 |
\newcommand\dbp@rev@lrl{\dbp@rlr} |
| 4322 |
% \end{macrocode} |
| 4323 |
% \end{macro} |
| 4324 |
% |
| 4325 |
% \begin{macro}{\dbp@rev@rlr} |
| 4326 |
% \begin{macrocode} |
| 4327 |
\newcommand\dbp@rev@rlr{\dbp@lrl} |
| 4328 |
% \end{macrocode} |
| 4329 |
% \end{macro} |
| 4330 |
% |
| 4331 |
% \begin{macro}{\dubinspath} |
| 4332 |
% \begin{macrocode} |
| 4333 |
\newcommand\dubinspath[1]{% |
| 4334 |
\pgfextra{ |
| 4335 |
\dubinspathset{#1} |
| 4336 |
\ifbool{dubinspathreverse}{ |
| 4337 |
\edef\dbp@newa{\dbp@b} |
| 4338 |
\edef\dbp@newb{\dbp@a} |
| 4339 |
\pgfmathsetmacro\dbp@newanga{180+\dbp@angb} |
| 4340 |
\pgfmathsetmacro\dbp@newangb{180+\dbp@anga} |
| 4341 |
\edef\dbp@newfirstangle{\dbp@lastangle} |
| 4342 |
\edef\dbp@newlastangle{\dbp@firstangle} |
| 4343 |
\edef\dbp@newmethod{rev@\dbp@method} |
| 4344 |
\edef\dbp@newlradius{\dbp@rradius} |
| 4345 |
\edef\dbp@newrradius{\dbp@lradius} |
| 4346 |
\dubinspathset{ |
| 4347 |
start point=\dbp@newa, |
| 4348 |
end point=\dbp@newb, |
| 4349 |
start angle=\dbp@newanga, |
| 4350 |
end angle=\dbp@newangb, |
| 4351 |
first angle=\dbp@newfirstangle, |
| 4352 |
last angle=\dbp@newlastangle, |
| 4353 |
left and right minimum radii=\dbp@newlradius pt and \dbp@newrradius pt, |
| 4354 |
method=\dbp@newmethod, |
| 4355 |
} |
| 4356 |
}{} |
| 4357 |
} |
| 4358 |
\csname dbp@\dbp@method\endcsname% |
| 4359 |
} |
| 4360 |
% \end{macrocode} |
| 4361 |
% \end{macro} |
| 4362 |
% |
| 4363 |
% \begin{macro}{\dbp@store} |
| 4364 |
% \begin{macro}{\dbp@get} |
| 4365 |
% \begin{macrocode} |
| 4366 |
\def\dbp@store#1#2{% |
| 4367 |
\expandafter\xdef\csname dbp@store@#1@#2\endcsname% |
| 4368 |
{\csname dbp@#2\endcsname}% |
| 4369 |
} |
| 4370 |
\def\dbp@get#1#2{% |
| 4371 |
\csname dbp@store@#1@#2\endcsname% |
| 4372 |
} |
| 4373 |
% \end{macrocode} |
| 4374 |
% \end{macro} |
| 4375 |
% \end{macro} |
| 4376 |
% \begin{macro}{\dbp@setparams} |
| 4377 |
% \begin{macrocode} |
| 4378 |
\def\dbp@setparams#1#2#3#4#5{% |
| 4379 |
% method, length, fisrt angle, middle param, last angle |
| 4380 |
\edef\dbp@method{#1} |
| 4381 |
\edef\dbp@length{#2} |
| 4382 |
\edef\dbp@firstangle{#3} |
| 4383 |
\edef\dbp@middleparam{#4} |
| 4384 |
\edef\dbp@lastangle{#5} |
| 4385 |
\ifdef{\dbp@storename}{ |
| 4386 |
\foreach \p in {method,length,firstangle,middleparam,lastangle}{ |
| 4387 |
\dbp@store{\dbp@storename}{\p} |
| 4388 |
} |
| 4389 |
}{} |
| 4390 |
} |
| 4391 |
% \end{macrocode} |
| 4392 |
% \end{macro} |
| 4393 |
% \begin{macro}{\dbp@updateparams} |
| 4394 |
% \begin{macrocode} |
| 4395 |
\def\dbp@updateparams#1#2#3#4#5{ |
| 4396 |
\ifpgfmathcond{#2<\dbp@length}{ |
| 4397 |
\dbp@setparams{#1}{#2}{#3}{#4}{#5} |
| 4398 |
}{} |
| 4399 |
} |
| 4400 |
% \end{macrocode} |
| 4401 |
% \end{macro} |
| 4402 |
% |
| 4403 |
% \begin{macrocode} |
| 4404 |
\tikzset{ |
| 4405 |
dubins path/.is family, |
| 4406 |
dubins path, |
| 4407 |
start point/.store in=\dbp@a, |
| 4408 |
start angle/.store in=\dbp@anga, |
| 4409 |
end point/.store in=\dbp@b, |
| 4410 |
end angle/.store in=\dbp@angb, |
| 4411 |
store/.store in=\dbp@storename, |
| 4412 |
use store/.style={ |
| 4413 |
method=\dbp@get{#1}{method}, |
| 4414 |
first angle=\dbp@get{#1}{firstangle}, |
| 4415 |
last angle=\dbp@get{#1}{lastangle}, |
| 4416 |
middle param=\dbp@get{#1}{middleparam}, |
| 4417 |
}, |
| 4418 |
minimum radius/.code={ |
| 4419 |
\pgfmathsetmacro\dbp@radius{#1} |
| 4420 |
\pgfmathsetmacro\dbp@rradius{#1} |
| 4421 |
\pgfmathsetmacro\dbp@lradius{#1} |
| 4422 |
}, |
| 4423 |
left and right minimum radii/.code args={#1 and #2}{ |
| 4424 |
\pgfmathsetmacro\dbp@lradius{#1} |
| 4425 |
\pgfmathsetmacro\dbp@rradius{#2} |
| 4426 |
\pgfmathsetmacro\dbp@radius{(\dbp@lradius + \dbp@rradius)/2} |
| 4427 |
}, |
| 4428 |
method/.store in=\dbp@method, |
| 4429 |
first angle/.store in=\dbp@firstangle, |
| 4430 |
last angle/.store in=\dbp@lastangle, |
| 4431 |
middle param/.store in=\dbp@midparam, |
| 4432 |
reverse/.is if=dubinspathreverse, |
| 4433 |
} |
| 4434 |
% \end{macrocode} |
| 4435 |
% |
| 4436 |
% \begin{macro}{\dubinspathset} |
| 4437 |
% \begin{macrocode} |
| 4438 |
\newcommand\dubinspathset[1]{\tikzset{dubins path,#1}} |
| 4439 |
% \end{macrocode} |
| 4440 |
% \end{macro} |
| 4441 |
% |
| 4442 |
% |
| 4443 |
% \begin{macro}{\dubinspathcalc} |
| 4444 |
% \begin{macrocode} |
| 4445 |
\newcommand\dubinspathcalc[1]{% |
| 4446 |
\begingroup |
| 4447 |
\dubinspathset{#1} |
| 4448 |
\tikzset{ |
| 4449 |
declare function={ |
| 4450 |
angtodist(\dbp@a,\dbp@r)={abs(\dbp@a)*.01745329*\dbp@r}; |
| 4451 |
modangr(\dbp@a,\dbp@b)={ |
| 4452 |
( |
| 4453 |
Mod(\dbp@a,360)<Mod(\dbp@b,360) |
| 4454 |
? |
| 4455 |
Mod(\dbp@a,360) |
| 4456 |
: |
| 4457 |
Mod(\dbp@a,360)-360)+\dbp@b-Mod(\dbp@b,360 |
| 4458 |
) |
| 4459 |
}; |
| 4460 |
modangl(\dbp@a,\dbp@b)={ |
| 4461 |
( |
| 4462 |
Mod(\dbp@a,360)<Mod(\dbp@b,360) |
| 4463 |
? |
| 4464 |
Mod(\dbp@a,360)+360 |
| 4465 |
: |
| 4466 |
Mod(\dbp@a,360))+(\dbp@b)-Mod(\dbp@b,360) |
| 4467 |
}; |
| 4468 |
}, |
| 4469 |
} |
| 4470 |
|
| 4471 |
\pgfmathsetmacro\dbp@radius{\dbp@rradius} |
| 4472 |
\pgfmathsetmacro\dbp@anga{mod((\dbp@anga)+180,360)-180} |
| 4473 |
\pgfmathsetmacro\dbp@angb{mod((\dbp@angb)+180,360)-180} |
| 4474 |
\path |
| 4475 |
let |
| 4476 |
\p{a}=(\dbp@a), |
| 4477 |
\p{b}=(\dbp@b), |
| 4478 |
\p{ar}=($(\p{a}) + (\dbp@anga-90:\dbp@radius pt)$), |
| 4479 |
\p{al}=($(\p{a}) + (\dbp@anga+90:\dbp@radius pt)$), |
| 4480 |
\p{br}=($(\p{b}) + (\dbp@angb-90:\dbp@radius pt)$), |
| 4481 |
\p{bl}=($(\p{b}) + (\dbp@angb+90:\dbp@radius pt)$) |
| 4482 |
in \pgfextra{ |
| 4483 |
\pgfinterruptpath |
| 4484 |
|
| 4485 |
% RSR (ar and br) |
| 4486 |
\dbp@anglebetween\dbp@rsrarbr{\p{ar}}{\p{br}} |
| 4487 |
\dbp@distancebetween\dbp@rsrdarbr{\p{ar}}{\p{br}} |
| 4488 |
\pgfmathsetmacro\dbp@rsrangone{Mod(\dbp@anga-\dbp@rsrarbr,360)} |
| 4489 |
\pgfmathsetmacro\dbp@rsrangtwo{Mod(\dbp@rsrarbr-\dbp@angb,360)} |
| 4490 |
\pgfmathsetmacro\dbp@rsrlen{\dbp@rsrdarbr} |
| 4491 |
\pgfmathsetmacro\dbp@rsrdist{ |
| 4492 |
angtodist(\dbp@rsrangone,\dbp@radius) |
| 4493 |
+\dbp@rsrlen |
| 4494 |
+angtodist(\dbp@rsrangtwo,\dbp@radius) |
| 4495 |
} |
| 4496 |
\dbp@setparams% |
| 4497 |
{rsr}{\dbp@rsrdist}{\dbp@rsrangone}{\dbp@rsrlen}{\dbp@rsrangtwo} |
| 4498 |
|
| 4499 |
% LSL (al and bl) |
| 4500 |
\dbp@anglebetween\dbp@lslalbl{\p{al}}{\p{bl}} |
| 4501 |
\dbp@distancebetween\dbp@lsldalbl{\p{al}}{\p{bl}} |
| 4502 |
\pgfmathsetmacro{\dbp@lslangone}{mod(\dbp@lslalbl-\dbp@anga+720,360)} |
| 4503 |
\pgfmathsetmacro{\dbp@lslangtwo}{mod(\dbp@angb-\dbp@lslalbl+720,360)} |
| 4504 |
\pgfmathsetmacro\dbp@lsllen{\dbp@lsldalbl} |
| 4505 |
\pgfmathsetmacro\dbp@lsldist{ |
| 4506 |
angtodist(\dbp@lslangone,\dbp@radius) |
| 4507 |
+\dbp@lsllen |
| 4508 |
+angtodist(\dbp@lslangtwo,\dbp@radius) |
| 4509 |
} |
| 4510 |
\dbp@updateparams% |
| 4511 |
{lsl}{\dbp@lsldist}{\dbp@lslangone}{\dbp@lsllen}{\dbp@lslangtwo} |
| 4512 |
|
| 4513 |
% RSL (ar and bl) |
| 4514 |
\dbp@distancebetween\dbp@rsldarbl{\p{ar}}{\p{bl}} |
| 4515 |
\pgfmathtruncatemacro\dbp@rslok{(\dbp@rsldarbl>=2*\dbp@radius)?1:0} |
| 4516 |
\ifnumequal{\dbp@rslok}{1}{ |
| 4517 |
\dbp@anglebetween\dbp@rslarbl{\p{ar}}{\p{bl}} |
| 4518 |
\pgfmathsetmacro\dbp@rslanglesup{ |
| 4519 |
asin(\dbp@radius/\dbp@rsldarbl*2)} |
| 4520 |
\pgfmathsetmacro\dbp@rslangone |
| 4521 |
{Mod(\dbp@anga-\dbp@rslarbl+\dbp@rslanglesup,360)} |
| 4522 |
\pgfmathsetmacro\dbp@rslangtwo |
| 4523 |
{Mod(\dbp@angb-\dbp@rslarbl+\dbp@rslanglesup,360)} |
| 4524 |
\pgfmathsetmacro\dbp@rsllen{veclen(\dbp@rsldarbl,\dbp@radius)} |
| 4525 |
\pgfmathsetmacro\dbp@rsldist{ |
| 4526 |
angtodist(\dbp@rslangone,\dbp@radius) |
| 4527 |
+\dbp@rsllen |
| 4528 |
+angtodist(\dbp@rslangtwo,\dbp@radius) |
| 4529 |
} |
| 4530 |
|
| 4531 |
\dbp@updateparams% |
| 4532 |
{rsl}{\dbp@rsldist}{\dbp@rslangone}{\dbp@rsllen}{\dbp@rslangtwo} |
| 4533 |
}{} |
| 4534 |
|
| 4535 |
% LSR (al and br) |
| 4536 |
\dbp@distancebetween\dbp@lsrdalbr{\p{al}}{\p{br}} |
| 4537 |
\pgfmathtruncatemacro\dbp@lsrok{(\dbp@lsrdalbr>=2*\dbp@radius)?1:0} |
| 4538 |
\ifnumequal{\dbp@lsrok}{1}{ |
| 4539 |
\dbp@anglebetween\dbp@lsralbr{\p{al}}{\p{br}} |
| 4540 |
\pgfmathsetmacro\dbp@lsranglesup{ |
| 4541 |
asin(\dbp@radius/\dbp@lsrdalbr*2)} |
| 4542 |
\pgfmathsetmacro\dbp@lsrangone |
| 4543 |
{Mod(\dbp@lsralbr+\dbp@lsranglesup-\dbp@anga,360)} |
| 4544 |
\pgfmathsetmacro\dbp@lsrangtwo |
| 4545 |
{Mod(\dbp@lsralbr+\dbp@lsranglesup-\dbp@angb,360)} |
| 4546 |
\pgfmathsetmacro\dbp@lsrlen{veclen(\dbp@lsrdalbr,\dbp@radius)} |
| 4547 |
\pgfmathsetmacro\dbp@lsrdist{ |
| 4548 |
angtodist(\dbp@lsrangone,\dbp@radius) |
| 4549 |
+\dbp@lsrlen |
| 4550 |
+angtodist(\dbp@lsrangtwo,\dbp@radius) |
| 4551 |
} |
| 4552 |
\dbp@updateparams% |
| 4553 |
{lsr}{\dbp@lsrdist}{\dbp@lsrangone}{\dbp@lsrlen}{\dbp@lsrangtwo} |
| 4554 |
}{} |
| 4555 |
|
| 4556 |
% LRL (al and bl) |
| 4557 |
\dbp@distancebetween\dbp@lrldalbl{\p{al}}{\p{bl}} |
| 4558 |
\pgfmathtruncatemacro\dbp@lrlok{(\dbp@lrldalbl<=4*\dbp@radius)?1:0} |
| 4559 |
\ifnumequal{\dbp@lrlok}{1}{ |
| 4560 |
\dbp@anglebetween\dbp@lrlalbl{\p{al}}{\p{bl}} |
| 4561 |
\pgfmathsetmacro\dbp@lrlangsup{acos(\dbp@lrldalbl/\dbp@radius/4)} |
| 4562 |
\pgfmathsetmacro\dbp@lrlangone{ |
| 4563 |
modangl(\dbp@lrlalbl+\dbp@lrlangsup,\dbp@anga-90)-(\dbp@anga-90)} |
| 4564 |
\pgfmathsetmacro\dbp@lrlangtwo{% |
| 4565 |
(\dbp@angb-90)-modangr(\dbp@lrlalbl+180-\dbp@lrlangsup,\dbp@angb-90)} |
| 4566 |
\pgfmathsetmacro\dbp@lrlangthree{360-2*(90-\dbp@lrlangsup)} |
| 4567 |
\pgfmathsetmacro\dbp@lrldist{ |
| 4568 |
angtodist(\dbp@lrlangone,\dbp@radius) |
| 4569 |
+angtodist(\dbp@lrlangthree,\dbp@radius) |
| 4570 |
+angtodist(\dbp@lrlangtwo,\dbp@radius) |
| 4571 |
} |
| 4572 |
\dbp@updateparams% |
| 4573 |
{lrl}{\dbp@lrldist}{\dbp@lrlangone}{\dbp@lrlangthree}{\dbp@lrlangtwo} |
| 4574 |
}{} |
| 4575 |
|
| 4576 |
% RLR (ar and br) |
| 4577 |
\dbp@distancebetween\dbp@rlrdarbr{\p{ar}}{\p{br}} |
| 4578 |
\pgfmathtruncatemacro\dbp@rlrok{(\dbp@rlrdarbr<=4*\dbp@radius)?1:0} |
| 4579 |
\ifnumequal{\dbp@rlrok}{1}{ |
| 4580 |
\dbp@anglebetween\dbp@rlrarbr{\p{ar}}{\p{br}} |
| 4581 |
\pgfmathsetmacro\dbp@rlrangsup{acos(\dbp@rlrdarbr/\dbp@radius/4)} |
| 4582 |
\pgfmathsetmacro\dbp@rlrangone{ |
| 4583 |
(\dbp@anga+90)-modangr(\dbp@rlrarbr-\dbp@rlrangsup,\dbp@anga+90)} |
| 4584 |
\pgfmathsetmacro\dbp@rlrangtwo{% |
| 4585 |
modangl(\dbp@rlrarbr+180+\dbp@rlrangsup,\dbp@angb+90)-(\dbp@angb+90)} |
| 4586 |
\pgfmathsetmacro\dbp@rlrangthree{360-2*(90-\dbp@rlrangsup)} |
| 4587 |
\pgfmathsetmacro\dbp@rlrdist{ |
| 4588 |
angtodist(\dbp@rlrangone,\dbp@radius) |
| 4589 |
+angtodist(\dbp@rlrangthree,\dbp@radius) |
| 4590 |
+angtodist(\dbp@rlrangtwo,\dbp@radius) |
| 4591 |
} |
| 4592 |
\dbp@updateparams% |
| 4593 |
{rlr}{\dbp@rlrdist}{\dbp@rlrangone}{\dbp@rlrangthree}{\dbp@rlrangtwo} |
| 4594 |
}{} |
| 4595 |
|
| 4596 |
\endpgfinterruptpath |
| 4597 |
}; |
| 4598 |
\endgroup |
| 4599 |
} |
| 4600 |
% \end{macrocode} |
| 4601 |
% \end{macro} |
| 4602 |
% \iffalse |
| 4603 |
%</tikzlibrarydubins.code.tex> |
| 4604 |
% \fi |
| 4605 |
% |
| 4606 |
% \PrintChanges |
| 4607 |
% |
| 4608 |
% { |
| 4609 |
% \setcounter{IndexColumns}{2} |
| 4610 |
% \let\code\relax |
| 4611 |
% \IndexPrologue{\section{Index} Italic numbers refer page where the |
| 4612 |
% corresponding entry is described; Underlined numbers refer to the |
| 4613 |
% code line of the definition; Roman numbers refer to the code lines |
| 4614 |
% where the entry is used.} |
| 4615 |
% |
| 4616 |
% \PrintIndex |
| 4617 |
% } |
| 4618 |
% \Finale |
| 4619 |
% |
| 4620 |
% \iffalse |
| 4621 |
%<*sankey-doc-preamble> |
| 4622 |
\usepackage[paper=a4paper,vmargin=1.5cm,left=4.5cm,right=3.5cm,marginparwidth=3.5cm]{geometry} |
| 4623 |
\usepackage[utf8]{inputenc} |
| 4624 |
\usepackage{cmap} |
| 4625 |
\usepackage[T1]{fontenc} |
| 4626 |
\usepackage{lmodern} |
| 4627 |
\usepackage{inconsolata} |
| 4628 |
\usepackage[final,protrusion=true,expansion=true]{microtype} |
| 4629 |
\usepackage{xcolor} |
| 4630 |
\PassOptionsToPackage{final,colorlinks,linkcolor=cyan!25!blue!75!black}{hyperref} |
| 4631 |
\usepackage{dtxdescribe} |
| 4632 |
\usepackage[numbered]{hypdoc} |
| 4633 |
\usepackage{fancyvrb} |
| 4634 |
\usepackage[final]{listings} |
| 4635 |
\usepackage{enumitem} |
| 4636 |
\usepackage{bookmark} |
| 4637 |
\usepackage{siunitx} |
| 4638 |
\usepackage{footnote} |
| 4639 |
\usepackage{etoc} |
| 4640 |
\usepackage{accsupp} |
| 4641 |
\usepackage{tikz} |
| 4642 |
\usetikzlibrary{positioning,patterns.meta,fit} |
| 4643 |
\usepackage[british]{babel} |
| 4644 |
\usepackage{varioref} |
| 4645 |
\usepackage{embedfile} |
| 4646 |
\usepackage{dtx-attach} |
| 4647 |
\embedfile[mimetype=text/plain]{sankey.ins} |
| 4648 |
\usepackage{sankey} |
| 4649 |
|
| 4650 |
\colorlet{bgcode}{yellow!50!gray!10} |
| 4651 |
\colorlet{keyword}{blue!50!cyan!50!black} |
| 4652 |
\colorlet{comment}{red!75!black} |
| 4653 |
|
| 4654 |
\newcommand\emptyaccsupp[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}} |
| 4655 |
|
| 4656 |
\lstset{ |
| 4657 |
literate= |
| 4658 |
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 |
| 4659 |
{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 |
| 4660 |
{à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1 |
| 4661 |
{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1 |
| 4662 |
{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1 |
| 4663 |
{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 |
| 4664 |
{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1 |
| 4665 |
{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1 |
| 4666 |
{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1 |
| 4667 |
{ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1 |
| 4668 |
{€}{{\texteuro}}1 {£}{{\pounds}}1 {°}{{\degres}}1 |
| 4669 |
{’}{{\textquoteright}}1 {‘}{{\textquoteleft}}1 |
| 4670 |
{«}{{<<}}1 {»}{{>>}}1 |
| 4671 |
{—}{{---}}1 {−}{{$-$}}1 |
| 4672 |
{\^\^A}{{}}0 % verbatim in .dtx file |
| 4673 |
} |
| 4674 |
|
| 4675 |
\lstset{ |
| 4676 |
fancyvrb=true, |
| 4677 |
escapechar=`, |
| 4678 |
extendedchars=true, |
| 4679 |
fontadjust=true, |
| 4680 |
columns=fullflexible, |
| 4681 |
flexiblecolumns=true, |
| 4682 |
inputencoding=utf8, |
| 4683 |
keepspaces=true, |
| 4684 |
backgroundcolor=\color{bgcode}, |
| 4685 |
basicstyle=\mdseries\ttfamily, |
| 4686 |
keywordstyle=\color{keyword}, |
| 4687 |
stringstyle=\ttfamily\color{green!50!black}, |
| 4688 |
commentstyle=\color{comment}\itshape, |
| 4689 |
emphstyle=\bfseries\color{red}, |
| 4690 |
numbersep=5pt, |
| 4691 |
%numbers=left, |
| 4692 |
numberstyle=\tiny\emptyaccsupp, |
| 4693 |
showstringspaces=false, |
| 4694 |
upquote=true, |
| 4695 |
aboveskip=.5\parskip, |
| 4696 |
belowskip=.5\parskip, |
| 4697 |
framexleftmargin=1pt, |
| 4698 |
framexrightmargin=1pt, |
| 4699 |
gobble=2, % \lstlisting code in .dtx |
| 4700 |
} |
| 4701 |
|
| 4702 |
\lstdefinestyle{textsmall}{basicstyle=\color{black}\small\mdseries\ttfamily} |
| 4703 |
\lstdefinestyle{textfootnotesize}{basicstyle=\color{black}\footnotesize\mdseries\ttfamily} |
| 4704 |
\lstdefinestyle{textscriptsize}{basicstyle=\color{black}\scriptsize\mdseries\ttfamily} |
| 4705 |
\lstdefinestyle{texttiny}{basicstyle=\color{black}\tiny\mdseries\ttfamily} |
| 4706 |
|
| 4707 |
\lstdefinestyle{bash}{ |
| 4708 |
language=bash, |
| 4709 |
backgroundcolor=\color{gray!10}, |
| 4710 |
} |
| 4711 |
\lstdefinestyle{bashsmall}{style=bash,style=textsmall} |
| 4712 |
\lstdefinestyle{bashfootnotesize}{style=bash,style=footnotesize} |
| 4713 |
\lstdefinestyle{bashscriptsize}{style=bash,style=scriptsize} |
| 4714 |
|
| 4715 |
\lstdefinestyle{LaTeX}{ |
| 4716 |
language=[LaTeX]TeX, |
| 4717 |
moretexcs={ |
| 4718 |
Lab, |
| 4719 |
LabSet, |
| 4720 |
Qty, |
| 4721 |
QtySet, |
| 4722 |
colorlet, |
| 4723 |
coordinate, |
| 4724 |
countries, |
| 4725 |
country, |
| 4726 |
countryname, |
| 4727 |
definecolor, |
| 4728 |
draw, |
| 4729 |
endcountry, |
| 4730 |
fill, |
| 4731 |
foreach, |
| 4732 |
hashband, |
| 4733 |
hdist, |
| 4734 |
hwidth, |
| 4735 |
node, |
| 4736 |
nodename, |
| 4737 |
path, |
| 4738 |
sankeyadvance, |
| 4739 |
sankeydubins, |
| 4740 |
sankeyend, |
| 4741 |
sankeyend, |
| 4742 |
sankeyfork, |
| 4743 |
sankeynode, |
| 4744 |
sankeynodealias, |
| 4745 |
sankeynodeend, |
| 4746 |
sankeynodestart, |
| 4747 |
sankeyoutin, |
| 4748 |
sankeyset, |
| 4749 |
sankeystart, |
| 4750 |
sankeyturn, |
| 4751 |
sankeyturnleft, |
| 4752 |
sankeyturnleftbackward, |
| 4753 |
sankeyturnright, |
| 4754 |
sankeyturnrightbackward, |
| 4755 |
sisetup, |
| 4756 |
startcountry, |
| 4757 |
tikzset, |
| 4758 |
turnandstop, |
| 4759 |
usepackage, |
| 4760 |
vdist, |
| 4761 |
} |
| 4762 |
} |
| 4763 |
\lstdefinestyle{LaTeXsmall}{style=LaTeX,style=textsmall} |
| 4764 |
\lstdefinestyle{LaTeXfootnotesize}{style=LaTeX,style=textfootnotesize} |
| 4765 |
\lstdefinestyle{LaTeXscriptsize}{style=LaTeX,style=textscriptsize} |
| 4766 |
\lstdefinestyle{LaTeXtiny}{style=LaTeX,style=texttiny} |
| 4767 |
|
| 4768 |
\def\code{\lstinline[basicstyle=\mdseries\ttfamily\color{red!50!black}]} |
| 4769 |
|
| 4770 |
\edef\samplecodename{\jobname-code.vrb} |
| 4771 |
|
| 4772 |
\newcommand\constant[1]{\textcolor{violet}{\texttt{#1}}} |
| 4773 |
\newcommand\ARG[1]{\texttt{\{#1\}}} |
| 4774 |
\newcommand\OPTARG[1]{\textcolor{green!50!black}{\texttt{[#1]}}} |
| 4775 |
\newcommand\VAR[1]{\textit{\texttt{\ensuremath{\langle}#1\ensuremath{\rangle}}}} |
| 4776 |
\newcommand\NOTE[1]{\leavevmode\marginpar{#1}} |
| 4777 |
|
| 4778 |
\def\mynobreakpar{\par\nobreak\@afterheading} |
| 4779 |
\def\docprefix#1{\texttt{\textcolor{gray}{#1}}} |
| 4780 |
\def\sankeykeysprefix{/sankey} |
| 4781 |
|
| 4782 |
\newenvironment{sankeyoption}[5][]{% [prefix] key, val, default, initially |
| 4783 |
\begingroup |
| 4784 |
% |
| 4785 |
\def\keypath{#1}% |
| 4786 |
\ifdefempty{\keypath}{\def\keypath{\sankeykeysprefix}}{}% |
| 4787 |
\def\key{#2}% |
| 4788 |
\def\val{#3}% |
| 4789 |
\def\default{#4}% |
| 4790 |
\def\initially{#5}% |
| 4791 |
%\setlength\parindent{\dimexpr.5\parindent\relax}% |
| 4792 |
% \vspace{.25\baselineskip plus .25\baselineskip minus 0mm} |
| 4793 |
\parfillskip 0pt plus 1fil% |
| 4794 |
\leavevmode% |
| 4795 |
\expandafter\DescribeKey\expandafter{\key}% |
| 4796 |
\ttfamily% |
| 4797 |
%\hspace*{-1cm}% |
| 4798 |
\textcolor{red!75!black}{\texttt{\docprefix{\keypath/}\key}}% |
| 4799 |
\ifdefempty{\val}{}{=\val}% |
| 4800 |
\hfill% |
| 4801 |
\ifdefempty{\default}{\null}{{\rmfamily (default:\,\constant{\default})}}% |
| 4802 |
\ifdefempty{\initially}{\null}{{\rmfamily (initially:\,\constant{\initially})}}% |
| 4803 |
\mynobreakpar% |
| 4804 |
\endgroup% |
| 4805 |
\parskip=.5\baselineskip plus .25\baselineskip minus .3\baselineskip |
| 4806 |
\parfillskip=30pt plus 1fil |
| 4807 |
\itemize[topsep=0pt,partopsep=0pt,itemsep=0pt]\item[] |
| 4808 |
}{% |
| 4809 |
\enditemize% |
| 4810 |
} |
| 4811 |
|
| 4812 |
\newcommand\MACRO{\hspace*{0cm}} |
| 4813 |
|
| 4814 |
\newlist{sankeyconstantsdesc}{description}{1} |
| 4815 |
\setlist[sankeyconstantsdesc]{align=right,labelindent=1.5em,labelsep=.5em,leftmargin=!,font=\normalfont} |
| 4816 |
|
| 4817 |
\newlength{\myparskip} |
| 4818 |
\setlength{\myparskip}{.75\baselineskip plus 8\baselineskip minus .25\baselineskip} |
| 4819 |
\usepackage[skip=\myparskip]{parskip} |
| 4820 |
\newenvironment{miniblock}{% |
| 4821 |
\vspace{.5\parskip}% |
| 4822 |
}{% |
| 4823 |
} |
| 4824 |
|
| 4825 |
\tikzset{ |
| 4826 |
every picture/.style={ |
| 4827 |
execute at end picture={ |
| 4828 |
\begin{pgfonlayer}{background} |
| 4829 |
\node[fit=(current bounding box),inner sep=0](bb){}; |
| 4830 |
\def\rs{5mm} |
| 4831 |
\draw[gray!25] let |
| 4832 |
\p{sw}=(bb.south west), \p{ne}=(bb.north east), |
| 4833 |
\n{maxx}={ceil(\x{ne}/\rs)*\rs}, \n{minx}={floor(\x{sw}/\rs)*\rs}, |
| 4834 |
\n{maxy}={ceil(\y{ne}/\rs)*\rs}, \n{miny}={floor(\y{sw}/\rs)*\rs} |
| 4835 |
in (\n{minx},\n{miny}) grid (\n{maxx},\n{maxy}); |
| 4836 |
\begin{scope}[overlay] |
| 4837 |
\draw[gray!50,-latex] let |
| 4838 |
\p{sw}=(bb.south west), \p{ne}=(bb.north east), |
| 4839 |
\n{maxx}={ceil(\x{ne}/\rs)*\rs}, \n{minx}={floor(\x{sw}/\rs)*\rs}, |
| 4840 |
\n{maxy}={ceil(\y{ne}/\rs)*\rs}, \n{miny}={floor(\y{sw}/\rs)*\rs} |
| 4841 |
in (\n{minx},0) -- (\n{maxx}+1mm,0); |
| 4842 |
\draw[gray!50,-latex] let |
| 4843 |
\p{sw}=(bb.south west), \p{ne}=(bb.north east), |
| 4844 |
\n{maxx}={ceil(\x{ne}/\rs)*\rs}, \n{minx}={floor(\x{sw}/\rs)*\rs}, |
| 4845 |
\n{maxy}={ceil(\y{ne}/\rs)*\rs}, \n{miny}={floor(\y{sw}/\rs)*\rs} |
| 4846 |
in (0,\n{miny}) -- (0,\n{maxy}+1mm); |
| 4847 |
\end{scope} |
| 4848 |
\end{pgfonlayer} |
| 4849 |
} |
| 4850 |
} |
| 4851 |
} |
| 4852 |
|
| 4853 |
\def\MacroFont{ |
| 4854 |
\fontencoding\encodingdefault |
| 4855 |
\fontfamily\ttdefault |
| 4856 |
\fontseries\mddefault |
| 4857 |
\fontshape\updefault |
| 4858 |
\footnotesize |
| 4859 |
} |
| 4860 |
|
| 4861 |
%</sankey-doc-preamble> |
| 4862 |
% \fi |
| 4863 |
\endinput |
| 4864 |
|
| 4865 |
% Local Variables: |
| 4866 |
% mode: doctex |
| 4867 |
% LaTeX-verbatim-macros-with-braces-local: ("code") |
| 4868 |
% TeX-master: t |
| 4869 |
% End: |