confidence interval on bar plot

85 views (last 30 days)
HL
HL on 12 Oct 2021
Commented: HL on 12 Oct 2021
I already have the mean calculated and the bar graph is acttually my 4 mean values. All I want to do is to show that I have 95% confidence interval for these values and indicate on the plot which of the groups are significantly different from one another.
For all other confidence interval tutorial I have looked at, they teach me from how to calculate the mean and obtain a confidence interval. However, I do not need to know these. I just wnat to know how to get that confidence interval bar on my bar plot.

Accepted Answer

Antti
Antti on 12 Oct 2021
Hi! I believe you could use the errorbar function. Here's an example:
% Create groups and data
X = categorical({'Small','Medium','Large','Extra Large'});
X = reordercats(X,{'Small','Medium','Large','Extra Large'});
Y = [10 21 33 52];
% Make a bar plot
bar(X,Y)
% Plot on top of bar plot
hold on
% errorbar(x,y,ci,marker) where ci is the height of the line. This can be
% computed from your confidence intervals.
errorbar([1 2 3 4],[10 21 33 52],[4 6 7 8],'o')
If this works for you, please formally accept this answer.
  1 Comment
HL
HL on 12 Oct 2021
Thank you so much!!! It worked perfectly as I wanted.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!