I am drawing a heatmap/scatter plot with the mark colour determined based on a score. I have mapped scores to Red, Green and Blue values, and trying to colour the marks based on the RGB values. The data are given in a csv file. I found the original code here and adopted to my case.
My problem is, I get below error when I try to read the data from my csv file. But if I copy the content in the csv into my .tex file it works fine.
How do I fix this error? or is there a better way to draw this plot?
Any help is much appreciated
! Missing number, treated as zero. t l.40 \end{groupplot} ?
This is the sample code.
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots} \pgfplotsset{compat=1.16}
\usepgfplotslibrary{groupplots}
\begin{filecontents*}{myfile.csv}
SAE;Affected categories;red;green;blue
0.01;2;204;0;255
0.01;3;204;0;255
0.02;25;24;8;255
0.03;17;113;45;255
0.04;2;204;0;255
\end{filecontents*}
\begin{document}
\pgfplotstableread[col sep = semicolon]{myfile.csv}\myfile
\begin{tikzpicture}%
\begin{groupplot}[]
\nextgroupplot[%
ylabel={Affected categories}
]%
\addplot[
scatter,%
scatter/@pre marker code/.code={%
\edef\temp{\noexpand\definecolor{mapped color}{RGB}{\pgfplotspointmeta}}%
\temp
\scope[draw=mapped color,fill=mapped color]%
},%
scatter/@post marker code/.code={%
\endscope
},%
only marks,
mark=*,
point meta={TeX code symbolic={%
\edef\pgfplotspointmeta{\thisrow{red},\thisrow{green},\thisrow{blue}}%
}},
]
table [x = {SAE}, y = {Affected categories}, col sep=semicolon]{\myfile};
\end{groupplot}
\end{tikzpicture}
\end{document}

\documentclass[tikz,border=3.14mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.16} \usepgfplotslibrary{groupplots} \begin{document}and\end{document}, I do not get an error message when compiling this on an updated TeXLive 2019 installation. So please provide us with a full document that starts with\documentclassand ends with\end{document}and tell us how you compile it such that we can help you. – Jul 14 '19 at 16:58filecontents(see e.g. https://tex.stackexchange.com/a/83929/121799 for how that works) that shows the problem. I am afraid that otherwise it will be next-to-impossible to find the reason. – Jul 14 '19 at 23:59\pgfplotstablereadis causing the problem – Niroshan Jul 15 '19 at 00:16\addplot[<your options>] table [x = {SAE}, y = {Affected categories}, col sep=semicolon]{myfile.csv};works beautifully. Unless you have an urgent reason to insist on] table [x = {SAE}, y = {Affected categories}, col sep=semicolon]{\myfile};, which, as you point out, has problems, I would recommend using the former. – Jul 15 '19 at 05:20