是否可以使用 LaTeX 创建如下所示的网络热图?
节点大小随 NodeData 中的“Wait”字段而变化,链接颜色根据 LinkData 中的“Flow”字段而变化。我知道使用 tikz 绘制网络,但不确定是否可以用 TeX 生成此类热图。
节点数据
nodeId lat long Wait
24 5 13 4426.0
20 5 32 0.0
21 5 22 0.0
22 13 22 0.0
23 13 13 0.0
1 51 5 2703.0
3 44 5 5421.0
2 51 32 1426.0
5 44 22 0.0
4 44 13 2703.0
7 38 42 3327.0
6 44 32 0.0
9 38 22 0.0
8 38 32 0.0
11 32 13 3588.0
10 32 22 0.0
13 5 5 2293.0
12 32 5 3564.0
15 19 22 0.0
14 19 13 2109.0
17 26 32 0.0
16 32 32 0.0
19 19 32 0.0
18 32 42 4420.0
链接数据
Id fromNodeId toNodeId fromNodeLat fromNodeLong toNodeLat toNodeLong Flow
0 5 6 44 22 44 32 0.0
0 18 20 32 42 5 32 505.0
0 21 22 5 22 13 22 0.0
0 2 1 51 32 51 5 240.0
0 12 3 32 5 44 5 350.0
0 14 15 19 13 19 22 0.0
0 9 10 38 22 32 22 0.0
0 21 20 5 22 5 32 0.0
0 9 5 38 22 44 22 0.0
0 15 14 19 22 19 13 0.0
0 16 8 32 32 38 32 0.0
0 11 10 32 13 32 22 0.0
0 17 10 26 32 32 22 0.0
0 12 11 32 5 32 13 1475.0
0 24 21 5 13 5 22 720.0
0 14 23 19 13 13 13 0.0
0 6 2 44 32 51 32 0.0
0 1 2 51 5 51 32 350.0
0 5 9 44 22 38 22 0.0
0 13 12 5 5 32 5 1105.0
0 10 11 32 22 32 13 0.0
0 1 3 51 5 44 5 590.0
0 4 11 44 13 32 13 0.0
0 3 12 44 5 32 5 295.0
0 6 8 44 32 38 32 0.0
0 22 23 13 22 13 13 0.0
0 7 8 38 42 38 32 0.0
0 22 15 13 22 19 22 0.0
0 19 15 19 32 19 22 0.0
0 5 4 44 22 44 13 0.0
0 3 4 44 5 44 13 855.0
0 11 12 32 13 32 5 1610.0
0 10 16 32 22 32 32 0.0
0 17 16 26 32 32 32 0.0
0 16 18 32 32 32 42 0.0
0 16 17 32 32 26 32 0.0
0 12 13 32 5 5 5 1175.0
0 24 23 5 13 13 13 0.0
0 23 14 13 13 19 13 0.0
0 23 22 13 13 13 22 0.0
0 22 20 13 22 5 32 0.0
0 20 19 5 32 19 32 0.0
0 8 16 38 32 32 32 0.0
0 11 4 32 13 44 13 0.0
0 8 6 38 32 44 32 0.0
0 20 21 5 32 5 22 0.0
0 10 17 32 22 26 32 0.0
0 16 10 32 32 32 22 0.0
0 18 16 32 42 32 32 0.0
0 7 18 38 42 32 42 1120.0
0 14 11 19 13 32 13 710.0
0 8 9 38 32 38 22 0.0
0 22 21 13 22 5 22 0.0
0 4 5 44 13 44 22 0.0
0 6 5 44 32 44 22 0.0
0 20 18 5 32 32 42 0.0
0 20 22 5 32 13 22 0.0
0 19 17 19 32 26 32 0.0
0 10 9 32 22 38 22 0.0
0 15 10 19 22 32 22 0.0
0 11 14 32 13 19 13 1410.0
0 15 19 19 22 19 32 0.0
0 3 1 44 5 51 5 700.0
0 23 24 13 13 5 13 0.0
0 18 7 32 42 38 42 983.076923077
0 13 24 5 5 5 13 850.0
0 21 24 5 22 5 13 0.0
0 2 6 51 32 44 32 0.0
0 24 13 5 13 5 5 770.0
0 9 8 38 22 38 32 0.0
0 19 20 19 32 5 32 0.0
0 4 3 44 13 44 5 910.0
0 15 22 19 22 13 22 0.0
0 8 7 38 32 38 42 0.0
0 17 19 26 32 19 32 0.0
0 10 15 32 22 19 22 0.0
答案1
这是一个TikZ
解决方案,我们使用包从 csv 文件中读取数据datatool
,然后使用xfp
包进行一些计算。希望您可以在此基础上进行任何必要的调整...
平均能量损失
\documentclass[margin=5mm]{standalone}
\usepackage{tikz,datatool,xfp}
\definecolor{zero}{rgb}{1,1,.5}
\tikzset{
Node/.style = {
fill = gray,
draw = none,
circle,
minimum width = \fpeval{1+sqrt(#1)/3},
},
Link/.style = {
line width = 1mm,
draw = {red!\fpeval{#1/20}!yellow!\fpeval{100*(#1>1)}!zero},
},
legend/.style = {
anchor = west,
},
}
\begin{document}
\begin{tikzpicture}
\DTLloaddb{nodes}{NodeData.csv}
\DTLforeach*{nodes}{\id=nodeId,\ny=lat,\nx=long,\nw=Wait}{%
\node[Node={\nw}](\id) at (\nx/5,\ny/5){};
}
\DTLloaddb{links}{LinkData.csv}
\DTLforeach*{links}{\nfr=fromNodeId,\nto=toNodeId,\flow=Flow}{%
\draw[Link={\flow}] (\nfr) -- (\nto);
}
\node[legend] at (10,9.75) {Wait Time (pass-min)};
\foreach \nw in {1,2,3,4,5}{
\node[Node={\nw*1000}] at (10.5,10-\nw) {};
\node[legend] at (11,10-\nw) {\nw000};
}
\node[legend] at (10,3.75) {Passenger Flow};
\foreach \flow in {0,1,2,3,4}{
\draw[Link={\flow*500}] (10.2,3-0.5*\flow) -- (10.8,3-0.5*\flow);
\node[legend] at (11,3-0.5*\flow) {\fpeval{\flow*500}};
}
\end{tikzpicture}
\end{document}