Filter löschen
Filter löschen

confidence interval on bar plot

85 Ansichten (letzte 30 Tage)
HL
HL am 12 Okt. 2021
Kommentiert: HL am 12 Okt. 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.

Akzeptierte Antwort

Antti
Antti am 12 Okt. 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 Kommentar
HL
HL am 12 Okt. 2021
Thank you so much!!! It worked perfectly as I wanted.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Errorbars finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by