필터 지우기
필터 지우기

errorbar on barplot of matrix of values

조회 수: 9 (최근 30일)
Rory
Rory 2011년 11월 1일
답변: Shikha Baghel 2019년 11월 11일
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?

답변 (3개)

Wayne King
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
Rory
Rory 2011년 11월 1일
Hi Wayne
I think you misunderstood the question. I have 30 Y values, 30 L values, and 30 U values. I want to make a bar chart. I know how to make a bar chart if I give the values as a vector, and I know how to make a bar chart by giving the values as a 6x5 matrix (i.e., there are 5 different colors of bars, and one bar of each color at each of the 6 implicit "x" values) , which is what I want. What I do not know is how to add my error bars to such a matrix-input type bar chart.
Amit Kenny
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.

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


Guido
Guido 2012년 5월 21일
Why doens't anybody answer this? I have exactly the same problem....

Shikha Baghel
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.

카테고리

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