errorbar on barplot of matrix of values
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (3)
Wayne King
il 1 Nov 2011
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 Commenti
Amit Kenny
il 12 Set 2013
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
il 21 Mag 2012
Why doens't anybody answer this? I have exactly the same problem....
0 Commenti
Shikha Baghel
il 11 Nov 2019
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 Commenti
Vedere anche
Categorie
Scopri di più su Errorbars in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!