Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}
\addplot [error bars/.cd, y dir=both, y explicit] coordinates {
    (1, 10) +- (0, 1)
    (2, 10) +- (0, 10)
    (3, 10) +- (0, 1)
};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}
share|improve this question
2  
Welcome to LaTeX! Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. Also consider registering your account. We can merge it with your previous question account. – percusse Aug 19 '12 at 13:41
Finally got my accounts merged :-) I also added an example, but I didn't find out how to display the output. – Vegard Aug 19 '12 at 20:34
@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
show 2 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.