I want to have my error bar graph like given in picture

조회 수: 2 (최근 30일)
Muhammad Usman
Muhammad Usman 2015년 7월 9일
clear all; clc;
C = [0.962 0.9416 0.9606 0.9845 0.9385];
N = [0.9392 0.979 0.948 0 0];
S = [0.9599 0.9276 0.9571 0.9339 0.9763];
xx = [C;N;S];
xx_error = xx/10;
h = bar(xx);
colormap(summer)
set(h,'BarWidth',0.8); % The bars will now touch each other
set(gca,'YGrid','on')
set(gca,'GridLineStyle','-')
set(gca,'XTicklabel','Cloudy|Night|Sunny')
set(get(gca,'YLabel'),'String','U')
lh = legend('Series1','Series2','Series3');
set(lh,'Location','BestOutside','Orientation','horizontal')
hold on;
numgroups = size(xx, 1);
numbars = size(xx, 2);
groupwidth = min(0.8, numbars/(numbars+1.5));
for i = 1:numbars
% Based on barweb.m by Bolu Ajiboye from MATLAB File Exchange
x = (1:numgroups) - groupwidth/2 + (2*i-1) * groupwidth / (2*numbars); % Aligning error bar with individual bar
errorbar(x, xx(:,i), xx_error(:,i), 'k', 'linestyle', 'none');
end

답변 (0개)

카테고리

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