How to barplot with standard deviation?

조회 수: 100 (최근 30일)
Pinga
Pinga 2014년 7월 9일
댓글: Star Strider 2014년 7월 21일
I've got following code so far:
if true
% code
end
load('Mean.mat') % Mean contains all mean values and consists of 5 rows
x = [time]; % define x-axis
y = [IC1,IC2,IC3,IC4]; % define y-axis
figure;
hBars = bar(y,1.0); % create bar plot with y;
set(gca,'XTickLabel',{'Baseline','0,1','0.2','0.3','0.4','0.5'});
% set ticks and tick labels
xlabel('Time');
ylabel('Impulse');
hold on;
load('standarddev.mat') % standarddev contains all calculated standard deviation and consists of 5 %rows
std = [sd1,sd2,sd3,sd4,sd5]; % define y-axis
errorbar(x,y,std);
title('Impulse');
legend('a','b','c','d','Location','SouthEastOutside')
% put in lower right
The plot itself works fine. I'd like to include the errorbars for the standard deviation as well but that unfortunately doesn't work at the moment. I've already had a look at the MATLAB Documentation Center bt without success.
Any help would be appreciated.

채택된 답변

Star Strider
Star Strider 2014년 7월 9일
We did this a few weeks ago in How to add errorbars. Be sure to read dpb’s answer as well.

추가 답변 (2개)

Pinga
Pinga 2014년 7월 10일
Thank you, I should have done that. In the meanwhile I did but it somehow still doesn't work. Only about the half of all errorbars are plotted and still not placed in the center top of the bars (see attachment).
Since I'm new to MATLAB, I would thankful for every suggestion on my code.
if true
% code
end
load('Mean.mat') % Mean contains all mean values and consists of 5 rows
load('Stddeviation.mat')
x = [time]; % define x-axis
y = [IC1,IC2,IC3,IC4]; % define y-axis
e = [std1,std2,std3,std4,std5,std6]; % define standard deviation
figure;
hBars = bar(y,1.0,'gropued');
set(gca,'XTickLabel',{'Baseline','0,1','0.2','0.3','0.4','0.5'});
% set ticks and tick labels
xlabel('Time');
ylabel('Impulse');
hold all;
for i = 1:6;
j = 1:4;
x = -0.5 + i + 1/5 *j;
errorbar(x,y,(j,i),e(j,i),'.'); % plotting errors
end
title('Impulse');
legend('a','b','c','d','Location','SouthEastOutside')
% put in lower right
box off;
hold off;
  댓글 수: 19
Pinga
Pinga 2014년 7월 21일
Great, thank you for everything!
Star Strider
Star Strider 2014년 7월 21일
My pleasure!
I’m sure with TMW’s help, you’ll get it sorted!

댓글을 달려면 로그인하십시오.


Pinga
Pinga 2014년 7월 10일
What I've tried is to switch the columns/rows since the last plot only showed four groups of errorbars. But that didn't solve the problem. I left the values for the standard deviation in this switched order.
That would be great, if anyone could help me - I've been trying for some days now to only plot these data.

카테고리

Help CenterFile Exchange에서 Errorbars에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by