# Global pgfplotset messing up error bars

I have a plot with some error bars generated with this code, but the error bars are messed up.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
every axis/.append style={
scale only axis,
},
/tikz/every picture/.append style={
baseline,
trim axis left,
trim axis right,
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=4.5in,
height=3.5in,
scale only axis,
xmode=log,
xmin=0.001,
xmax=1,
xminorticks=true,
ymin=0,
ymax=250
]
plot [error bars/.cd, y dir = both, y explicit]
table[row sep=crcr, y error plus index=2, y error minus index=3]{0.0625469 25.07   0.25    0.25\\
0.0390918   54.77   0.649999999999999   0.649999999999999\\
0.0244324   154.33  1.5 1.5\\
0.0152702   200 5.5 5.5\\
0.00954391  208.67  5.5 5.5\\
0.00596494  215.33  6   6\\
0.00372809  219 2.5 2.5\\
0.00233006  220.67  5   5\\
0.00145628  221 1.5 1.5\\
};
\end{axis}
\end{tikzpicture}%
\end{document}


But if I remove

\pgfplotsset{
every axis/.append style={
scale only axis,
},
/tikz/every picture/.append style={
baseline,
trim axis left,
trim axis right,
}
}


It looks fine. The problem is like that pgfplotset command early in my document to control all alignment and axis trimming. Any solutions?

Thanks

Move the arguments trim axis left and trim axis right from the pgfplotsset to the tikzpicture environment:

Code

\documentclass[border=1cm]{standalone}%{article}
\usepackage{pgfplots}
\pgfplotsset{
every axis/.append style={
scale only axis,
},
/tikz/every picture/.append style={
baseline,
}
}
\begin{document}
\begin{tikzpicture}[trim axis left,
trim axis right]
\begin{axis}[%
width=4.5in,
height=3.5in,
scale only axis,
xmode=log,
xmin=0.001,
xmax=1,
xminorticks=true,
ymin=0,
ymax=250
]
plot [error bars/.cd, y dir = both, y explicit]
table[row sep=crcr, y error index=2, y error index=3]{0.0625469 25.07   0.25    0.25\\
0.0390918   54.77   0.649999999999999   0.649999999999999\\
0.0244324   154.33  1.5 1.5\\
0.0152702   200 5.5 5.5\\
0.00954391  208.67  5.5 5.5\\
0.00596494  215.33  6   6\\
0.00372809  219 2.5 2.5\\
0.00233006  220.67  5   5\\
0.00145628  221 1.5 1.5\\
};
\end{axis}
\end{tikzpicture}%
\end{document}

• Whats with the \[ when you meant just [? Also, might be useful to consider automating this solution as it seems the OP always wants those options. May 23, 2014 at 5:12
• @PeterGrill -- I don't know why it gets there, my PC does not have it. I will re-post it soon. May 23, 2014 at 5:13
• @Jesse Hi, thanks yes this does work. It is probably the solution but as mentioned by Peter it would be nice if I can globally define trim axis left and right in the preamble. Thanks May 23, 2014 at 6:21
• @SteveHatcher -- Actually, in your current setting, mark out trim axis left would work too in my exhausted test. I observed trim left is the culprit because if you mark out the other one and leave trim left alone, the problem persists. To me that is not logic, so I proposed the current solution, moving them to the tikz environment. Hope this info helps. May 23, 2014 at 6:53