Get errorbars to work with categorical bar plot

I have a set of mean values to plot in a categorical bar plot. However when I add errorbars for the standard deviation it pops up with the errors
Error using errorbar>checkSingleInput (line 271)
YNegativeDelta must be empty or the same size as YData.
Error in errorbar (line 135)
yneg = checkSingleInput(neg, sz, 'YNegativeDelta');
Error in DAE5descriptiv (line 53)
errorbar(y,error)
Anyone got a solution that isn't too complicated to implement? I am using Matlab 2018. I tried posting this problem in our university forum, but apparently my professors were unable to find a solution :P
x = categorical({'Overall','Audio','AudioVisual'}); %Makes 3 categories
y = [70.68,46.92,65.24;69.73,44.15,60.63;71.50,49.31,69.22]; %Mean data
error = [8.4 6.8 8.0 8.4 6.6 7.8 8.4 7.0 8.3]; %SD data
bar(x,y) %Makes bar plot
errorbar(y,error) %NOT WORKING!
legend('Skill','Quality','Pleasantness'); %Gives each color the according name

1 Kommentar

Shot in the dark:
errorbar(y(:),error)
Unfortunately not. It gives this result: http://prntscr.com/n00flj
What I need is something like this, but with errorbars: http://prntscr.com/n00fw2

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KALYAN ACHARJYA
KALYAN ACHARJYA am 19 Mär. 2019
Bearbeitet: KALYAN ACHARJYA am 19 Mär. 2019

0 Stimmen

whos y
Name Size Bytes Class Attributes
y 3x3 72 double
>> whos error
Name Size Bytes Class Attributes
error 1x9 72 double
How can you do that in errorbar(y,error)? Size Issue
Are you looking this one?
x=categorical({'Overall','Audio','AudioVisual'}); %Makes 3 categories
y=[70.68,46.92,65.24;69.73,44.15,60.63;71.50,49.31,69.22]; %Mean data
error = [8.4 6.8 8.0;8.4 6.6 7.8;8.4 7.0 8.3]; %SD data
figure, bar(x,y) %Makes bar plot
figure, errorbar(y,error);
legend('Skill','Quality','Pleasantness'); %Gives each color the according name
Please Note: I did not check the logic of the code

Kategorien

Gefragt:

am 19 Mär. 2019

Kommentiert:

am 20 Mär. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by