Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I am now plotting some bars and pictures for use in presentation. Really interested in different ways of showing confidence intervals on the plots.

share|improve this question
4  
Are you looking for general aesthetic guidance? Or statistical guidance on what is best to report? Or particular ways of doing it in a particular software package? Please be more specific. – Aaron Jun 16 '11 at 15:30

2 Answers

As Aaron has pointed out, it is not quite clear what you are actually asking for.

Here is an example of bars with confidence intervals, which I think does the job bars with confidence intervals

It was produced in R using the package ggplot2 and the following code based on the example in the help page for geom_errorbar

library(ggplot2)
df <- data.frame( trt = factor(c(1, 1, 2, 2)), resp = c(1, 5, 3, 4), 
                  group = factor(c(1, 2, 1, 2)), se = c(0.1, 0.3, 0.3, 0.2) )
# Define the top and bottom of the errorbars
ci <- aes(ymax = resp + 1.96*se, ymin=resp - 1.96*se)
p <- ggplot(df, aes(fill=group, y=resp, x=trt))
# Because the bars and errorbars have different widths
# we need to specify how wide the objects we are dodging are
dodge <- position_dodge(width=0.9)
p + geom_bar(position=dodge) + geom_errorbar(ci, position=dodge, width=0.25)
share|improve this answer

If you like to do it in MATLAB, you can use errorbar. Alternatively, you may check the confidence interval plotting utilities in MATLAB file exchange. For instance, errorb is a nice function to do different types of confidence interval plots.

clc, clear, close

y=rand(1,5)+1; e=rand(1,5)/4;
hold off; bar(y,'facecolor',[.8 .8 .8]); hold on;
errorb(y,e);

figure
x=linspace(0,2*pi,8); y=sin(x); e=rand(1,8)/4;
hold off; plot(x,y,'k','linewidth',2); hold on;
errorb(x,y,e)

figure
values=abs(rand(2,3))+1; errors=rand(2,3)/1.5+0;
errorb(values,errors,'top');

Error plot 1

Error plot 2

Error plot 3

There are other alternatives in file exchange such as #1, #2 and #3.

share|improve this answer

Your Answer

 
discard

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

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