errorbar on barplot of matrix of values
조회 수: 9 (최근 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!