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
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
相关文章推荐
- Matlab求方差,均值,均方差,协方差的函数
- MATLAB函数中get函数
- matlab的几个取整函数
- matlab GUI
- 求平均排序MATLAB code
- matlab 2015a找不到编译器
- GradeDescent algorithm (Matlab Code)
- matlab find函数详解
- MATLAB——scatter的简单应用
- matlab一次读取多张图片
- matlab2014a下载、安装、破解步骤以及LibSVM 在matlab中的使用
- MATLAB中cell数组的是是非非
- Matlab绘图
- matlab如何使用legend只标注某几条曲线
- plot a critical difference diagram , MATLAB code
- MATLAB实现矩阵分块相乘
- 稀疏表示字典的显示(MATLAB实现代码)
- matlab----标签图像分类训练工具
- matlab----标签图像分类训练工具
- MATLAB使用频率方法的运动检测