フィルターのクリア

Bar with errorbars on the same figure

16 ビュー (過去 30 日間)
Lily
Lily 2013 年 8 月 29 日
編集済み: Guillem Heinrich 2017 年 7 月 20 日
Hi
I'm trying to plot bar with errorbars on the same figure. I tryed to use barweb (<http://www.mathworks.com/matlabcentral/fileexchange/10803-barweb-bargraph-with-error-bars>) but it doesn't seem to work. Is there an inbuilt function in Matlab?
The data I'm working with is similar to this:
mean_velocity = [0.2574, 0.1225, 0.1787]; % mean velocity
std_velocity = [0.3314, 0.2278, 0.2836]; % standard deviation of velocity

回答 (2 件)

the cyclist
the cyclist 2013 年 8 月 29 日
There is not a built-in for this, but you can superpose an errorbar() chart with a bar chart:
mean_velocity = [0.2574, 0.1225, 0.1787]; % mean velocity
std_velocity = [0.3314, 0.2278, 0.2836]; % standard deviation of velocity
figure
hold on
bar(1:3,mean_velocity)
errorbar(1:3,mean_velocity,std_velocity,'.')
I feel that this may not be exactly what you want, but it should give you an idea of what is possible
  10 件のコメント
chaitra
chaitra 2017 年 3 月 14 日
figure
hold on
bar(1:9,mean_velocity1)
errorbar(1:9,mean_velocity1,std_velocity1,'.')
figure
hold on
group = [mean_velocity1 mean_velocity2];
bar(1:9,mean_velocity2)
errorbar(1:9,mean_velocity2,std_velocity2,'.')
figure
hold on
gives me separate graphs. How shall I compare them in 1 plot with different colors?
Guillem Heinrich
Guillem Heinrich 2017 年 7 月 20 日
編集済み: Guillem Heinrich 2017 年 7 月 20 日
@chaitra You are creating a new figure for the second plot --> comment the fifth line of your code.

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


Leidy Castro Meneses
Leidy Castro Meneses 2017 年 3 月 10 日
編集済み: Leidy Castro Meneses 2017 年 3 月 10 日
Hi Based on the previous answer, I figured this script out:
young= [458.05,509.63]; %values are for young and old respectively
young2= [458.05,509.63,200,340];
old= [200,340];
group = [young;old];
SEM=[12,12,56,45]; % values for error bars
figure
hold on
bar(1:2,group)
errorbar([0.86,1.14,1.86,2.14],young2,SEM,'.') %errorbar(x,y,err)
  1 件のコメント
chaitra
chaitra 2017 年 3 月 14 日
How to change colors ?([0.86,1.14,1.86,2.14], what is the use of this?

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

カテゴリ

Help Center および File ExchangeErrorbars についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by