I have a list of (angles/value) pairs. I'd like to use TikZ to
- draw nodes with those values at these angles (easy),
- then draw an edge from node i to i+1, with the value of node i as a label (not at all easy).
My idea so far: store the values in pgfkeys, with keys the same as the node names. Then, values could be easily accessed. Problem is, I cannot get the pgfkeyssetvalue to evalute the node name first.
Example:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [dotted] (0,0) circle (2cm);
% draw nodes on a circle, remembering their value fails:
\foreach \angle/\value [count = \i] in {0/17, 45/22, 80/5, 140/12} {
\node [circle, draw, fill=white] (p\i) at (\angle:2cm) {\value};
\pgfkeyssetvalue{/nodevalues/p\i}{\value}
}
% to illustrate that it works with explicit node names:
\pgfkeyssetvalue{/nodevalues/p1}{17}
\pgfkeyssetvalue{/nodevalues/p2}{22}
% edges:
\foreach [evaluate = {\j=int(mod(\i, 4)+1)}] \i in {1,...,4}
\draw [->] (p\i) to [bend right=45] node[midway] {\pgfkeysvalueof{/nodevalues/p\i}} (p\j) ;
\end{tikzpicture}
\end{document}
This draws the edges for the manually set keys /nodevalues/p1 and /nodevalues/p2 correctly. But pgfkeyssetkeys does not do what I like. Expected result would be that 5->12 arc is label with 5, and 12->17 with 12.





Not sure what you have in mind with array?
– Holger Karl Aug 21 '18 at 15:52