TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have error bars representing 95% confidence intervals in a logarithmic plot. Some of the error bars extend to negative numbers for which the logarithm is undefined, so pgfplots simply drops the bar completely. Is there a way to make it plot e.g. a dashed line that extends all the way down to the axis instead?


\addplot [error bars/.cd, y dir=both, y explicit] coordinates {
    (1, 10) +- (0, 1)
    (2, 10) +- (0, 10)
    (3, 10) +- (0, 1)
share|improve this question
@Vegard: This would take a bit of work. Could you explain the situation where you encounter a linearly symmetric confidence interval but need to plot the data logarithmically? Are negative values for your data even possible? Maybe it would be more correct to calculate the confidence interval for the logarithmic transformed data? – Jake Aug 23 '12 at 12:29
@Jake You're correct, negative values are not possible. Calculating the confidence interval for the log-transformed data would give a confidence interval for the geometric rather than the arithmetic mean, however. I'm using a nonparametric bootstrap sample to obtain the confidence interval (so there are no assumptions about the distribution), but maybe this is wrong. – Vegard Aug 23 '12 at 12:40
@Vegard: I guess you calculated the confidence intervals using 1.96 times the standard deviation as obtained from the bootstrapping? In that case, you'd be assuming a normal distribution (which for strictly positive data isn't true). Instead, I think you'll have to use a different method for obtaining the confidence interval. See math.usask.ca/~longhai/doc/talks/slide-bootstrap.pdf for a simple introduction and jstor.org/stable/2246110 for a more in-depth discussion. – Jake Aug 23 '12 at 13:09
Even if one can solve the technical problem of convincing pgfplots to do something the result will look very weird since the (logarithmic) domain of the graph will be dominated by the negative error bar. – alfC Sep 22 '12 at 1:30
@JosephWright: In this case, I'm actually not sure whether this should be an answer: While in this concrete case it might not make sense to plot the negative error bars, there could be situations where it does (though I can't think of one), so maybe someone will come up with an actual answer. – Jake Sep 8 '13 at 10:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.