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 件のコメント

madhan ravi
madhan ravi 2019 年 3 月 20 日
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

サインインしてコメントする。

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 3 月 19 日
編集済み: KALYAN ACHARJYA 2019 年 3 月 19 日

0 投票

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

1 件のコメント

Mikkel Hansen
Mikkel Hansen 2019 年 3 月 19 日
Unfortunately not. I need something like this, but with errorbars ontop: http://prntscr.com/n00fw2

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeErrorbars についてさらに検索

質問済み:

2019 年 3 月 19 日

コメント済み:

2019 年 3 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by