0

I have a working code. Unfortunately though, it appears as if the error bars are being added twice. Once in blue and once in gray. I don't understand what is causing this. How can I fix it? Here is the data file data.csv.

\documentclass[crop,tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
 \begin{axis}[
    width=\linewidth,
    legend style={nodes={scale=0.5, transform shape}, anchor=north east}, 
    xmin = 0, xmax = 30,
    ymin = 45, ymax =65,
    xlabel= {Time[s]},
    ylabel={ST},
    error bars/y dir=both,
    error bars/y explicit]
    
    \addplot+[ color=blue, mark=., thin, error bars/.cd, error mark options={gray}]
    table[col sep=comma, x=Base_T, y=Base_ST, y error=Base_SD] {data.csv} ;
    \addlegendentry{Baseline}
    
    \addplot+[ color=green,mark=., thin]
    table[col sep=comma, x=pn_T, y=pn_ST] {data.csv} ;  
    \addlegendentry{Test1};   
 \end{axis}
\end{tikzpicture}
\end{document}

This results in the following diagram: enter image description here

1
  • Unrelated: When using PGFPlots, remember to always set the compat level - see my answer Commented May 3, 2022 at 12:56

1 Answer 1

1

Maybe this is the result you expect:

\begin{filecontents}{data.csv}
Base_T, Base_ST, Base_SD
8,48,1
15,50,2
20,55,2
\end{filecontents}
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 30,
ymin = 45, ymax =65,
xlabel= {Time[s]},
ylabel={ST},
error bars/y dir=both,
error bars/y explicit,
]
\addplot[blue, mark=none, error bars/error mark options={gray, rotate=90}]
table[col sep=comma, x=Base_T, y=Base_ST, y error=Base_SD] {data.csv};
\end{axis}
\end{tikzpicture}
\end{document}

Graph with gray error bars

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .