您的位置:首页 > 编程语言 > MATLAB

Matlab 条形图绘制 以及 添加误差棒 改变条形图形状

2015-12-17 17:36 761 查看
首先绘制条形图 主要采用matlab自带的bar命令

a_live = [0.9186, 0.9460, 0.9552, 0.9533];

a_tid = [0.6090, 0.6663, 0.7170, 0.7165];

a = [a_live; a_tid];

bar(a, 'grouped')

set(gca,'YLim', [0.5,1], 'XTickLabel',{'LIVE', 'TID2013'}, 'FontSize', 15);

ylabel('SRC');

set(gca, 'Ytick', [0.5:0.05:1], 'ygrid','on','GridLineStyle','-');

legend('25','50','100','200', 'Location', 'EastOutside');

legend('boxoff');



采用errorbar命令添加误差棒,这里的误差是标准差。

e = [0.0198, 0.0124, 0.0096, 0.0112; 0.0875, 0.0990, 0.1034, 0.0939];

hold on

numgroups = size(a, 1);

numbars = size(a, 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, a(:,i), e(:,i), 'k', 'linestyle', 'none', 'lineWidth', 1);

end



最后采用一个toolbox: applyhatch_pluscolor_bundle来改变条形图的形状,方便黑白打印的时候显示

[im_hatch,colorlist] = applyhatch_pluscolor(1,'\+x.', 1, [1,0,1,0] , [], [], 1.5, 2); % add different patterns

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: