Get errorbars to work with categorical bar plot
Afficher commentaires plus anciens
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 commentaire
madhan ravi
le 20 Mar 2019
Shot in the dark:
errorbar(y(:),error)
Réponses (1)
KALYAN ACHARJYA
le 19 Mar 2019
Modifié(e) : KALYAN ACHARJYA
le 19 Mar 2019
whos y
Name Size Bytes Class Attributes
y 3x3 72 double
>> whos error
Name Size Bytes Class Attributes
error 1x9 72 double
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

1 commentaire
Mikkel Hansen
le 19 Mar 2019
Catégories
En savoir plus sur Errorbars dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!