1

In the following MWE, the lines and vertical error bars have the correct width, but not the horizontal bars. How do I set them to 'very thick'? Also, is there a way to control their length? Finally, is there a way to set the error bars to solid, while having the line being dashed?

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{/pgfplots/error bars/error bar style={very thick}}
\pgfplotsset{
  every axis plot/.append style={very thick, black},
}

\begin{document}
\begin{tikzpicture}
  \begin{axis}
    \addplot [dashed, mark=asterisk, error bars/.cd, y dir=both, y explicit]
    table [x=x, y=y, y error=y-err]{%
      x y y-err
      0 0 0.5
      1 1 0.5
      2 2 0.5
      3 3 0.5
      4 4 0.5
    };
  \end{axis}
\end{tikzpicture}
\end{document}
2

Yes, using error bar style={line width=...} you can increase the thickness of the bar. With the error mark options you can customise the marks above and below. (See this answer here):

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{/pgfplots/error bars/error bar style={very thick}}
\pgfplotsset{
  every axis plot/.append style={very thick, black},
}

\begin{document}
\begin{tikzpicture}
  \begin{axis}
    \addplot [dashed, mark=asterisk, error bars/.cd, y dir=both, y explicit,
      error bar style={line width=2pt,solid},
      error mark options={line width=1pt,mark size=4pt,rotate=90}]
    table [x=x, y=y, y error=y-err]{%
      x y y-err
      0 0 0.5
      1 1 0.5
      2 2 0.5
      3 3 0.5
      4 4 0.5
    };
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

(Edit: added note on error mark options, second edit: added dashed to plot and solid to error bar style)

  • This does not change the horizontal small bar above and below every point. – Tohiko Feb 17 '18 at 23:11
  • You can use error mark options to further customise the small bars at the end of the error bars. – Jasper Habicht Feb 17 '18 at 23:21
  • Thanks! That's exactly what I was looking for. Is there a way to have the line dashed while the error bar solid? – Tohiko Feb 17 '18 at 23:24
  • Well, add dashed to the error mark options, but I don’t know how you exactly picture the result. I guess, you have to increase the mark size to mark size=7.5pt in order to get a reasonable result – Jasper Habicht Feb 17 '18 at 23:28
  • Sorry, I misunderstood you. To undash the error bars, put solid to the error bar style. The mark will then also be solid. – Jasper Habicht Feb 17 '18 at 23:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.