6

Is it possible to create the network heatmap using LaTeX as the one below?

Network Heatmap

The node size vary with the "Wait" field in the NodeData and link color changes according to the "Flow" fieled in the LinkData. I am aware of drawing the network using the tikz but not sure if such heatmap can be generated with TeX.

NodeData

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

LinkData

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
  • 2
    TikZ is part of LaTeX. LaTeX is on top of TeX. It is not clear what you want as you write conflicting things. -also you need to show what you have tried. May 13, 2021 at 13:31

1 Answer 1

8

Here is a TikZ solution where we read in the data from csv files using the datatool package, and we do some calculations using xfp package. Hopefully you can make any needed adjustments on top of this...

MWE

\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}

Result

result

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.