在 matlab 环境下显示柱形图,用于比较多次试验的结果,其中字体倾斜部分参考了别人的代码。
地址:http://blog.csdn.net/susu_love/article/details/53257043
- clc;
- clear all;
- filename = 'E:\result.xlsx';
- original = xlsread(filename);
- data = original(2:9,1:10);
- MinCol = min(data);
- MaxCol = max(data);
- MinValue = min(MinCol);
- MaxValue = max(MaxCol);
- %% 显示8个图像集10次检测的结果
- figure(1)
- bar(data');
- axis([0 11 0.9 1.0]); %设置横轴和纵轴坐标的范围
- colormap(cool);
- hold on;
- legend('record(12783)','StudentsArea(1258)','VS2(914)','Ncast(561)','yks(599)',...
- 'PositiveTest(2456)','AllObject(18571)','NoObject(27151)','Location','NorthEastOutside'); //设置图形标注
- xlabel('次数');
- ylabel('准确率');
- title('检测准确率(10次)');
- %% 显示8个图像集10次检测结果的均值
- Average = original(2:9,11);
- Average = diag(Average);
- figure(2)
- b = bar(Average,'stacked');
- axis([0 9 0.9 1.0]);
- color=[0 0 1];
- set(b(1),'FaceColor',color(1,:));
- % colormap(cool);
- hold on;
- set(gca,'XTick',[1 2 3 4 5 6 7 8]);
- set(gca,'XTickLabel',{'record','StudentsArea','VS2','Ncast','yks',...
- 'PositiveTest','AllObject','NoObject'}); //设置横坐标的标注文字
- h = gca;
- th = rotateticklabel(h, 35); % 字体倾斜35度,此处可以参考,有用
- ylabel('准确率');
- title('10次均值');
运行结果如下图所示: