Here is the file:
data
I can't get the following code to work. Apparently adding and subtracting the rows is the problem. Am I missing something here?
\documentclass[crop,tikz]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=\linewidth,
xmin = 0, xmax = 90,
ymin = 45, ymax =65,
xlabel= {Time[s]},
ylabel={ST},
error bars/y dir=both, % turn on error bars
error bars/y explicit]
%upper line for the interval
\addplot[name path=upper, fill=none, draw=none] table[col sep=comma, x=pn_T, y expr=\thisrow{pn_ST} + \thisrow{pn_SD}]{data.csv};
%lower line for the interval
\addplot[name path=lower, fill=none, draw=none] table[col sep=comma, x=pn_T, y expr=\thisrow{pn_ST} - \thisrow{pn_SD}]{data.csv};
%fill between the lines
\addplot[green!40] fill between[of=lower and upper];
%add the two plots
\addplot+[ color=blue, mark=., thin, error bars/error bar style={gray}] table[col sep=comma, x=Base_T, y=Base_ST, y error=Base_SD] {data.csv} ;
\addplot+[ color=green,mark=., thin] table[col sep=comma, x=pn_T, y=pn_ST] {data.csv} ;
\end{axis}
\end{tikzpicture}
\end{document}
I Get the following error when I try to compile the code in my main document:
! Package PGF Math Error: Could not parse input '' as a floating point number, sorry. The unreadable part was near ''. (in ' + '). See the PGF Math package documentation for explanation. Type H for immediate help. ... l.13 ...n_ST} + \thisrow{pn_SD}]{data/tritonad.csv}; This error message was generated by an \errmessage command, so I can't give any explicit help. Pretend that you're Hercule Poirot: Examine all clues, and deduce the truth by order and method.
pn_STfor the given row but this cell is empty. You should check in your CSV whether there are maybe rows with only empty values. – Jasper Habicht Aug 02 '22 at 10:27\pgfkeys{/pgf/fpu/handlers/empty number/.code={\pgfmathparse{0}}}to your preamble. This will tell PGF to handle any empty string as zero. But you should actually look into your CSV file for empty values and set them tonan(see https://tex.stackexchange.com/q/83735/47927). – Jasper Habicht Aug 02 '22 at 12:41\pgfkeys{/pgf/fpu/handlers/empty number/.code={\pgfmathparse{nan}}}might be more accurate. – Jasper Habicht Aug 02 '22 at 12:55