errorbar on barplot of matrix of values
10 次查看(过去 30 天)
显示 更早的评论
I have five columns and six rows of data, so that there will be six series each with 5 bars of different color:
data=
1.0e+003 *
0.1903 0.5921 0.9474 1.0812 1.1512
0.9046 3.0476 3.3224 3.3349 3.4622
0.1942 0.6398 1.1746 1.8845 1.8825
0.2514 0.6010 1.2010 1.6336 2.0561
1.3790 2.8521 3.6485 4.1223 4.3366
0.5420 2.2191 3.4601 4.3508 4.2623
bar(data)
Now for each of these 30 values, I have a U(i,j) and a L(i,j) that I want to use to put error bars on the graph:
hold on
errorbar(X, data, Umatrix, Lmatrix, 'LineStyle','none','Color','k')
Basically my question is: what should I put in as X in order for the error bars to be properly placed on the bars?
0 个评论
回答(3 个)
Wayne King
2011-11-1
Hi,
y = mean(data);
errors = std(data);
x = 1:size(data,2);
bar(x, y)
hold on;
h = errorbar(x, y, errors);
set(h,'linestyle','none')
2 个评论
Amit Kenny
2013-9-12
I have the same problem and the errorbar function do not work. when x is a vector (n*1), y is a matrix (n*m), and errors is a matrix (n*m), I'm getting an error massage
??? Error using ==> errorbar at 76
X, Y and error bars must all be the same length
The same error massage is received when the vector and matrixes are taken in transpose.
Shikha Baghel
2019-11-11
y = [65.97005 68.83499
59.91751 60.12435
74.71612 76.70728]
err = [1.4534 1.17742
3.81131 3.80832
1.75479 1.71148 ]
x=[1 1;
2 2;
3 3];
figure;
bar(x,y) ; hold on;
er = errorbar(x,y,err); hold off;
Here, y is a 3X2 matrix and err is also of same size. The output figure will have separate error bars for each bars. You can adjust the x-axis location of each error bar using property inspector of MATLAB. I am using MATLAB R2019a.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Errorbars 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!