[MATLAB] bar chart

1. Bar comparison chart

 x=[1 2 3 4];
 y=[20 80;2 98;10 90;75 25]; 
 figureHandle = figure;
 bar(x,y);
 hYLabel1 = ylabel('Percentage (%)');
 hLegend = legend( 'RT-Follow<---', 'NetWork Model' ,'Location', 'northwest');

set(gca, 'FontName', 'Helvetica', 'FontSize', 10)
 
set(gca,'xTicklabel',{
    
    'Run Time','Train Time','HardwareCost','SensorSupportType'})
fileout = 'test';
print(figureHandle,[fileout,'.png'],'-r600','-dpng');

insert image description here

2. Bar chart

mydata=[56.3,61.26,50.0,72.7];
 figureHandle = figure(1)

hold on
for i = 1:length(mydata)
    if mydata(i) ==56.3 
        h=bar(i,mydata(i),'FaceColor',[0 .5 .5]);
%         set(h,'FaceColor','b');
    elseif mydata(i) ==61.26
        h=bar(i,mydata(i));
%         set(h,'FaceColor','r');
   elseif mydata(i) ==50.0
       h=bar(i,mydata(i));
%         set(h,'FaceColor','g');
    else mydata(i) ==72.7
        h=bar(i,mydata(i));
    end
end
set(gca, 'FontName', 'Helvetica', 'FontSize', 15)
set(gca,'xtick',[1 2 3 4]); % 故意为了只是显示5个刻度值,下方的设置才有效
set(gca,'xticklabel',{
    
    'ResNet50','SeResNet-50','T-ReDet Module','RT-Follow'});
 ylabel('MOTA (%)') ;
hold off
fileout = 'test';
set(gcf,'unit','normalized','position',[0.2,0.2,0.64,0.64]);
print(figureHandle,[fileout,'.png'],'-dpng');

insert image description here

3. Change position

 x=[1 2 3 4];
 y=[95 20;22 50;19 38;100 5]; 
 figureHandle = figure;
 bar(x,y);
 hLegend = legend( 'RT-Follow<---', '传统导航' ,'Location', 'north');

set(gca, 'FontName', 'Helvetica', 'FontSize', 10)
 
set(gca,'xTicklabel',{
    
    '通过率(%)','时间(s)','路径(m)','是否躲避快速动态障碍物'})
fileout = 'test';
print(figureHandle,[fileout,'.png'],'-r600','-dpng');

insert image description here

Guess you like

Origin blog.csdn.net/xi_shui/article/details/128453976