0

I have seen many questions about error bars but is there a simple command that allows me to add, for example, a constant 5% or 0.1 error on all my points in the x/y direction. All the questions I have seen have complex commands for customizing the error on each which I do not want.

Thank you! (Sorry if this is a repeat)

1
  • Welcome to TeX.SE! I guess you will have a better chance to get the desired answer if you provide an MWE, or, at least a picture illustrating what you want. You can certainly change the symbol for the marks, if that's your question.
    – user121799
    Commented Feb 18, 2018 at 5:48

1 Answer 1

4

Sure you can do this. Here an example adapted from the PGFPlots manual with (fixed) relative x errors and fixed/constant y errors added to all plots of an axis environment.

% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        error bars/x dir=both,
        error bars/x fixed relative=0.5,
        error bars/y dir=both,
        error bars/y fixed=0.1,
    ]
        \addplot table {
            x   y
            0   0
            0.1 0.1
            0.2 0.2
            0.5 0.5
            1   1
        };
        \addplot+ [
            domain=0:1,
            samples=5,
        ] {x^2};
    \end{axis}
\end{tikzpicture}
\end{document}

image showing the result of above code

4
  • How would I add it to just one plot? Commented Feb 20, 2018 at 23:42
  • Simply move all the error bars/... options to the \addplot options, i.e. \addplot [error bars/...] .... Commented Feb 21, 2018 at 6:07
  • for some reason it gives me the error "i do not know the key to /pgfplots/table/error bars/y dir to which you passed 'both', ..." How do I fix this for tables? Commented Feb 23, 2018 at 12:24
  • nevermind, figured it out! You have to add another command box before table! Commented Feb 23, 2018 at 12:27

You must log in to answer this question.

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