I have such a plot and have now asked whether it is suitable from an academic point of view. It was suggested to me to ‘dodge’ the error bars (see here). Unfortunately, this is done with ggplot2
. Is it also possible to do this in LaTeX
and tikz
?
This is the code:
\documentclass{article}\usepackage{tikz}\usepackage{acronym}\usepackage{pgfplots}\usepackage{xcolor}\usepackage{subcaption}\usepackage[margin=1in]{geometry}\pgfplotsset{compat=1.18}\begin{document}\begin{figure} \begin{tikzpicture} \centering \begin{axis}[ width=\textwidth, height=0.5\textwidth, xlabel={\footnotesize $x$}, ylabel={\footnotesize $y$}, xmin=0, xmax=0.1, ymin=8, ymax=16, grid=major, title={\footnotesize a)}, tick label style={font=\scriptsize}, title style={at={(-0.15,1.15)}, anchor=north west}, xtick={0,0.02,0.04,0.06,0.08,0.10}, xticklabel style={/pgf/number format/fixed, /pgf/number format/precision=2}, legend style={ font=\footnotesize, legend columns=-1, cells={anchor=west}, draw=black, rounded corners=3pt, inner xsep=3pt, inner ysep=2pt, column sep=5pt, }, legend to name=commonlegend ] \addplot[ color=red, mark=*, solid, error bars/.cd, error bar style={line width=1pt}, y dir=both, y explicit ] coordinates { (0.00,8) += (0,0.3) -= (0,0.1) (0.02,8.2) += (0,0.3) -= (0,0.1) (0.04,8.5) += (0,0.3) -= (0,0.1) (0.06,8.8) += (0,0.3) -= (0,0.1) (0.08,9) += (0,0.3) -= (0,0.1) (0.10,9.2) += (0,0.3) -= (0,0.1) }; \addlegendentry{Variant 1a} \addplot[ color=red, mark=square*, densely dashed, error bars/.cd, error bar style={line width=1pt}, y dir=both, y explicit ] coordinates { (0.00,8) += (0,0.3) -= (0,0.1) (0.02,8.5) += (0,0.3) -= (0,0.1) (0.04,9) += (0,0.3) -= (0,0.1) (0.06,9.5) += (0,0.3) -= (0,0.1) (0.08,10) += (0,0.3) -= (0,0.1) (0.10,10.5) += (0,0.3) -= (0,0.1) }; \addlegendentry{Variant 1b} \addplot[ color=blue, mark=*, solid, error bars/.cd, error bar style={line width=1pt}, y dir=both, y explicit ] coordinates { (0.00,8) += (0,0.3) -= (0,0.1) (0.02,9) += (0,0.3) -= (0,0.1) (0.04,10) += (0,2.6) -= (0,0.1) (0.06,11) += (0,0.3) -= (0,0.1) (0.08,12) += (0,0.3) -= (0,0.1) (0.10,13) += (0,0.3) -= (0,0.1) }; \addlegendentry{Variant 2a} \addplot[ color=blue, mark=square*, densely dashed, error bars/.cd, error bar style={line width=1pt}, y dir=both, y explicit ] coordinates { (0.00,8) += (0,0.3) -= (0,0.1) (0.02,9.5) += (0,0.3) -= (0,0.1) (0.04,11) += (0,0.3) -= (0,0.1) (0.06,12) += (0,0.3) -= (0,0.1) (0.08,13) += (0,0.3) -= (0,0.1) (0.10,13.5) += (0,0.3) -= (0,0.1) }; \addlegendentry{Variant 2b} \addplot[ color=orange, mark=*, solid, error bars/.cd, error bar style={line width=1pt}, y dir=both, y explicit ] coordinates { (0.00,8) += (0,0.3) -= (0,0.1) (0.02,10) += (0,0.3) -= (0,0.1) (0.04,11.5) += (0,0.3) -= (0,0.1) (0.06,12.5) += (0,0.3) -= (0,0.1) (0.08,13.5) += (0,0.3) -= (0,0.1) (0.10,14) += (0,0.3) -= (0,0.1) }; \addlegendentry{Variant 3a} \addplot[ color=orange, mark=square*, densely dashed, error bars/.cd, error bar style={line width=1pt}, y dir=both, y explicit ] coordinates { (0.00,8) += (0,0.3) -= (0,0.1) (0.02,10) += (0,0.3) -= (0,0.1) (0.04,12) += (0,0.3) -= (0,0.1) (0.06,13) += (0,0.3) -= (0,0.1) (0.08,14) += (0,0.3) -= (0,0.1) (0.10,14.5) += (0,0.3) -= (0,0.1) }; \addlegendentry{Variant 3b} \end{axis} \end{tikzpicture}\ref{commonlegend}\end{figure}\end{document}
And here you can see the overlaps, f.e. for $x=0.04$.Image may be NSFW.
Clik here to view.