1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
\begin{tikzpicture}[rotate=-90]
\begin{sankeydiagram}[rotate=-90]
\sffamily
\sankeyset{
ratio=1.7cm/10,
outin steps=2,
start style=arrow,
end style=simple,
draw/.style={draw=white,line width=.4pt},
color/.style={fill/.style={fill=#1,fill opacity=.75}},
shade/.style 2 args={fill/.style={
fill=none,line width=0,
top color=#1,bottom color=#2,
middle color=#1!50!#2!50!white,
fill opacity=.75}},
% colors
@define HTML color/.code args={#1/#2}{\definecolor{#1}{HTML}{#2}},
@define HTML color/.list={
cyan/a6cee3,lime/b2df8a,red/fb9a99,orange/fdbf6f,
violet/cab2d6,yellow/ffff99,blue/1f78b4,green/33a02c
},
% colors of countries
@let country color/.code args={#1/#2}{\colorlet{#1}[rgb]{#2}},
@let country color/.list={
CA/red,US/orange,MX/lime,BR/violet,FR/yellow,GB/blue,
SP/green,PT/cyan,ML/cyan,SN/red,MA/orange,
AO/violet,ZA/lime,IN/blue,JP/yellow,CN/green
},
}
\def\vdist{5mm}
\def\hwidth{1em}
\def\hdist{6cm}
\sankeynode{name=CA,quantity=7}
\sankeynode{name=US,quantity=8,at={[yshift=\vdist]CA.left},anchor=right}
\sankeynode{name=MX,quantity=8,at={[yshift=\vdist]US.left},anchor=right}
\sankeynode{name=BR,quantity=8,at={[yshift=\vdist]MX.left},anchor=right}
\foreach \country in {CA,US,MX,BR}{
\sankeystart[color=\country]{\country}
\sankeyadvance[color=\country]{\country}{\hwidth}
}
\sankeyfork{CA}{1/CA-to-PT,1/CA-to-GB,5/CA-to-FR}
\sankeyfork{US}{1/US-to-PT,1/US-to-SP,5/US-to-GB,1/US-to-FR}
\sankeyfork{MX}{1/MX-to-PT,5/MX-to-SP,1/MX-to-GB,1/MX-to-FR}
\sankeyfork{BR}{5/BR-to-PT,1/BR-to-SP,1/BR-to-GB,1/BR-to-FR}
\sankeynode{name=FR,quantity=11,
at={[xshift=\hdist]CA.right},anchor=right}
\sankeynode{name=GB,quantity=11,
at={[yshift=\vdist]FR.left},anchor=right}
\sankeynode{name=SP,quantity=7,
at={[yshift=\vdist]GB.left},anchor=right}
\sankeynode{name=PT,quantity=8,
at={[yshift=\vdist]SP.left},anchor=right}
\sankeyfork{FR}
{1/FR-from-BR,1/FR-from-MX,1/FR-from-US,5/FR-from-CA,3/FR-from-00}
\sankeyfork{GB}
{1/GB-from-BR,1/GB-from-MX,5/GB-from-US,1/GB-from-CA,3/GB-from-00}
\sankeyfork{SP}{1/SP-from-BR,5/SP-from-MX,1/SP-from-US}
\sankeyfork{PT}{5/PT-from-BR,1/PT-from-MX,1/PT-from-US,1/PT-from-CA}
\foreach \country in {FR,GB,SP,PT}{
\sankeyadvance[color=\country]{\country}{\hwidth}
}
\sankeyfork{FR}{1/FR-to-ZA,1/FR-to-AO,3/FR-to-MA,3/FR-to-SN,3/FR-to-ML}
\sankeyfork{GB}{7/GB-to-ZA,1/GB-to-AO,2/GB-to-MA,1/GB-to-SN}
\sankeyfork{SP}{1/SP-to-ZA,3/SP-to-MA,1/SP-to-SN,2/SP-to-00}
\sankeyfork{PT}{3/PT-to-ZA,2/PT-to-AO,1/PT-to-MA,1/PT-to-SN,1/PT-to-00}
\sankeynode{name=ML,quantity=9,
at={[xshift=\hdist]FR.right},anchor=right}
\sankeynode{name=SN,quantity=9,
at={[yshift=\vdist]ML.left},anchor=right}
\sankeynode{name=MA,quantity=9,
at={[yshift=\vdist]SN.left},anchor=right}
\sankeynode{name=AO,quantity=9,
at={[yshift=\vdist]MA.left},anchor=right}
\sankeynode{name=ZA,quantity=12,
at={[yshift=\vdist]AO.left},anchor=right}
\sankeyfork{ML}{3/ML-from-FR,6/Mail-from-00}
\sankeyfork{SN}
{1/SN-from-PT,1/SN-from-SP,1/SN-from-GB,3/SN-from-FR,3/SN-from-00}
\sankeyfork{MA}{1/MA-from-PT,3/MA-from-SP,2/MA-from-GB,3/MA-from-FR}
\sankeyfork{AO}{2/AO-from-PT,1/AO-from-GB,1/AO-from-FR,5/AO-from-00}
\sankeyfork{ZA}{3/ZA-from-PT,1/ZA-from-SP,7/ZA-from-GB,1/ZA-from-FR}
\foreach \country in {ML,SN,MA,AO,ZA}{
\sankeyadvance[color=\country]{\country}{\hwidth}
}
\sankeyfork{ML}{5/ML-to-CN,3/ML-to-JP,1/ML-to-IN}
\sankeyfork{SN}{5/SN-to-CN,3/SN-to-JP,1/SN-to-IN}
\sankeyfork{MA}{5/MA-to-CN,3/MA-to-JP,1/MA-to-IN}
\sankeyfork{AO}{5/AO-to-CN,3/AO-to-JP,1/AO-to-IN}
\sankeyfork{ZA}{5/ZA-to-CN,3/ZA-to-JP,1/ZA-to-IN,3/ZA-to-00}
\sankeynode{name=IN,quantity=5,
at={[xshift=\hdist]ML.right},anchor=right}
\sankeynode{name=JP,quantity=15,
at={[yshift=\vdist]IN.left},anchor=right}
\sankeynode{name=CN,quantity=25,
at={[yshift=\vdist]JP.left},anchor=right}
\sankeyfork{IN}
{1/IN-from-ZA,1/IN-from-AO,1/IN-from-MA,1/IN-from-SN,1/IN-from-ML}
\sankeyfork{JP}
{3/JP-from-ZA,3/JP-from-AO,3/JP-from-MA,3/JP-from-SN,3/JP-from-ML}
\sankeyfork{CN}
{5/CN-from-ZA,5/CN-from-AO,5/CN-from-MA,5/CN-from-SN,5/CN-from-ML}
\foreach \country in {IN,JP,CN}{
\sankeyadvance[color=\country]{\country}{\hwidth}
\sankeyend[color=\country]{\country}
}
\foreach \startcountry/\countries in {
CA/{PT,GB,FR}, US/{PT,SP,GB,FR}, MX/{PT,SP,GB,FR},
BR/{PT,SP,GB,FR}, FR/{ML,SN,MA,AO,ZA}, GB/{SN,MA,AO,ZA},
SP/{SN,MA,ZA}, PT/{SN,MA,AO,ZA}, ML/{IN,JP,CN},
SN/{IN,JP,CN}, MA/{IN,JP,CN}, AO/{IN,JP,CN},
ZA/{IN,JP,CN}}
{
\foreach \endcountry in \countries {
\sankeyoutin[shade={\startcountry}{\endcountry}]
{\startcountry-to-\endcountry}{\endcountry-from-\startcountry}
}
}
\foreach \country/\countryname in {CA/Canada, US/USA, MX/Mexico,
BR/Brazil, FR/France, GB/England, SP/Spain, PT/Portugal}
{
\node[anchor=south,inner sep=.1em,font=\small]
at (\country) {\countryname\vphantom{Ag}};
}
\foreach \country/\countryname in {
ML/Mali, SN/Senegal, MA/Morocco, AO/Angola,
ZA/South Africa, IN/India, JP/Japan, CN/China}
{
\node[anchor=south,inner sep=.1em,font=\small]
at (\country) {\countryname\vphantom{Ag}};
}
\end{sankeydiagram}
\end{tikzpicture}
|