I am trying to access values from a file one by one, and using the following code to do it:
\nextgroupplot[
width=0.3*\plotwidth,
]
\foreach \i in {1,...,10}{
\foreach \j in {0,...,9}{
\ifnum\i>\j
\pgfplotstablegetelem{\i}{\j}\of{\first};
%\let\param\pgfplotsretval;
%\node at (axis cs:1.5, 0.5) {\pgfplotsretval};
\addplot [draw=none, mark=, fill=blue, fill opacity=1] coordinates {(0.5+\j, -0.5+\i)} node[pos=0.1] {\pgfplotsretval};
\else
\fi
}
}
Unfortunately, it does not work, and I fail to see the problem. Interestingly, when I use
\node at (axis cs:1.5, 0.5) {\pgfplotsretval};
it works -- almost, since it only gives me the first digit of the numbers in the table.
P.S. By the way, I am not using this to just put numbers in a grid. It is a debugging step, I will eventually use the values to draw colours from a \colormap.
MWE:
\begin{filecontents*}{data.csv}
1 2 3 4 5 6 7 8 9 10
0.1 0 0 0 0 0 0 0 0 0
0.05625 0.012499999999999999 0 0 0 0 0 0 0 0
0.05185185185185186 0.008101851851851851 0.003703703703703704 0 0 0 0 0 0 0
0.05078125 0.007031249999999999 0.0026331018518518517 0.0015625 0 0 0 0 0 0
0.0504 0.00665 0.002251851851851852 0.00118125 0.0008000000000000001 0 0 0 0 0
0.05023148148148148 0.006481481481481481 0.0020833333333333333 0.0010127314814814816 0.0006314814814814816 0.00046296296296296303 0 0 0 0
0.05014577259475219 0.006395772594752186 0.0019976244466040384 0.0009270225947521866 0.0005457725947521867 0.0003772540762336681 0.0002915451895043732 0 0 0
0.050097656250000004 0.006347656249999999 0.001949508101851852 0.00087890625 0.00049765625 0.0003291377314814815 0.00024342884475218656 0.00019531249999999998 0 0
0.050068587105624146 0.006318587105624142 0.0019204389574759945 0.0008498371056241427 0.00046858710562414275 0.00030006858710562417 0.00021435970037632926 0.00016624335562414266 0.00013717421124828533 0
0.050050000000000004 0.006299999999999999 0.0019018518518518518 0.0008312500000000001 0.0004500000000000001 0.0002814814814814815 0.00019577259475218658 0.00014765625 0.00011858710562414267 0.0001
\end{filecontents*}
\documentclass[margin=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepackage{pgfplotstable}
\usepgfplotslibrary{groupplots}
\definecolor{color1}{RGB}{202,0,32}
\definecolor{color2}{RGB}{244,165,130}
\definecolor{color3}{RGB}{146,197,222}
\definecolor{color4}{RGB}{5,113,176}
\def \plotwidth {510.0pt}
\begin{document}
\pgfplotstableread[col sep=tab]{data/first_order.dat}{\first}
\begin{tikzpicture}
\begin{groupplot}[
group style = {
group size = 3 by 1,
horizontal sep = 0pt,
yticklabels at=edge left,
},
height = 150pt,
width = \plotwidth,
xmin=0, xmax=10,
ymin=0, ymax=10,
xtick = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5},
ytick = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5},
]
\nextgroupplot[
width=0.3*\plotwidth,
]
\foreach \i in {1,...,5}{
\foreach \j in {0,...,3}{
\ifnum\i>\j
\pgfplotstablegetelem{\i}{\j}\of{\first};
\addplot [draw=none, mark=, fill=blue, fill opacity=1] coordinates {(0.5+\j, -0.5+\i)} node[pos=0.1] {\pgfplotsretval};
\else
\fi
}
}
\nextgroupplot[
width=0.3*\plotwidth
]
\nextgroupplot[
width=0.3*\plotwidth
]
\end{groupplot}
\end{tikzpicture}
\end{document}
readarray
package for getting file data into accessible array structures.