How to assign error bars to a multiple data sets histogram ?
이전 댓글 표시
I want to compared to conditions, with 6 values in each. I have this for th moment (fig.1) :
Sans=[21, 4, 4, 18, 7, 6];
Avec=[18, 3, 4, 14, 7, 27];
Comparaison=[Sans',Avec']
figure
bar(1:6,Comparaison)
legend('Sans','Avec');
When I use only one data set I manage to assign error bars, like this (fig.2):
Ect_type_sans=[7, 4, 3, 9, 7, 8];
bar(Sans)
hold on
errorbar(1:6,Sans,Ect_type_sans,'ko')
I would like to assign error bars to the first histogram, with Ect_type_sans for the Sans data and Ect_type_avec=[6, 3, 2, 5, 6, 8] for the Avec data. Any ideas ?
채택된 답변
추가 답변 (2개)
Jonas
2021년 7월 18일
use
myBars=bar(1:6,Comparaison);
this will give you a 1x2 bar in the variable myBars in this case. One bar object holds the 'avec' data, the other the 'sans'. each bar objects carries twoporpertirs from which you can calculate the position of the bars. one property is the XEndPoints (accessed eg by mybar(1).XEndPoints) which carries the end Po nts of the bars of the their respective data set. the other property is the BarWidth property (accessed eg by mybar(1).BarWidth). from that you can calculate the center of your bars and place your errorbars like you did in the single example
카테고리
도움말 센터 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

