一、代码
clear;
clc;
figure('position',[150,100,900,550])%确定图片的位置和大小,[x y width height]
%准备数据
Y1=[0.53,7.9,8.3;0.52,6.8,9.2;0.52,5.9,8.6;2.8,5.8,7.9;3.9,5.2,7.8;1.8,5.8,8.4]; % withoutNHC
X1=1:6;
%画出4组柱状图,宽度1
h1=bar(X1,Y1,1);
%修改横坐标名称、字体
set(gca,'XTickLabel',{'1','2','3','4','5','6'},'FontSize',10,'FontName','Arial');
% 设置柱子颜色,颜色为RGB三原色,每个值在0~1之间即可
set(h1(1),'FaceColor',[30,150,252]/255)
set(h1(2),'FaceColor',[162,214,249]/255)
set(h1(3),'FaceColor',[252,243,150]/255)
ylim([0,12]); %y轴刻度
%修改x,y轴标签
ylabel('\fontname{Arial}\fontsize{14}Position error(m)');
xlabel('\fontname{Arial}\fontsize{14}The number of groups');
%修改图例
% legend({'\fontname{Arial}例\fontname{Arial}East','\fontname{Arial}例\fontname{Arial}North','\fontname{Arial}例\fontname{Arial}Up'},'FontSize',11);hold on; % 保持当前图形
Y2= [0.48,2.1,4.7;0.47,2.3,4.9;0.46,2.1,4.8;2.7,3.4,3.5;3.7,3.6,3.3; 1.5,3.4,3.8]; % withNHC
X2=1:6;
h2=bar(X2,Y2,1);
set(h2(1),'FaceColor',[30,120,252]/255)
set(h2(2),'FaceColor',[122,214,249]/255)
set(h2(3),'FaceColor',[252,243,100]/255)
ylim([0,18]); %y轴刻度
ylabel('\fontname{Arial}\fontsize{14}Position error(m)');
xlabel('\fontname{Arial}\fontsize{14}The number of groups');
legend({'\fontname{Arial}\fontname{Arial}East(Without NHC)','\fontname{Arial}\fontname{Arial}North(Without NHC)','\fontname{Arial}\fontname{Arial}Up(Without NHC)','\fontname{Arial}\fontname{Arial}East(With NHC)','\fontname{Arial}\fontname{Arial}North(With NHC)','\fontname{Arial}\fontname{Arial}Up(With NHC)'},'FontSize',11);figure('position',[150,100,900,550])%确定图片的位置和大小,[x y width height]
%准备数据
Y1= [27.2,72.3,28.9;25.2,70.1,26.6;18.6,48.7,8.4;5.7,33.2,25.4;15.7,25.6,28.4;15.7,25.6,27.4]; % withoutNHC
X1=1:6;
%画出4组柱状图,宽度1
h1=bar(X1,Y1,1);
%修改横坐标名称、字体
set(gca,'XTickLabel',{'1','2','3','4','5','6'},'FontSize',10,'FontName','Arial');
% 设置柱子颜色,颜色为RGB三原色,每个值在0~1之间即可
set(h1(1),'FaceColor',[30,150,252]/255)
set(h1(2),'FaceColor',[162,214,249]/255)
set(h1(3),'FaceColor',[252,243,150]/255)
ylim([0,100]); %y轴刻度
%修改x,y轴标签
ylabel('\fontname{Arial}\fontsize{14}Position error(m)');
xlabel('\fontname{Arial}\fontsize{14}The number of groups');
%修改图例
% legend({'\fontname{Arial}例\fontname{Arial}East','\fontname{Arial}例\fontname{Arial}North','\fontname{Arial}例\fontname{Arial}Up'},'FontSize',11);hold on; % 保持当前图形
Y2 = [21.2,1.3,3.4;19.2,1.4,3.6;16.3,1.5,3.4;5.0,3.2,0.4; 9.2,3.1,0.3;4.7,3.5,4.8]; % withNHC
X2=1:6;
h2=bar(X2,Y2,1);
set(h2(1),'FaceColor',[30,120,252]/255)
set(h2(2),'FaceColor',[122,214,249]/255)
set(h2(3),'FaceColor',[252,243,100]/255)
ylim([0,100]); %y轴刻度
ylabel('\fontname{Arial}\fontsize{14}Position error(m)');
xlabel('\fontname{Arial}\fontsize{14}The number of groups');
legend({'\fontname{Arial}\fontname{Arial}East(Without NHC)','\fontname{Arial}\fontname{Arial}North(Without NHC)','\fontname{Arial}\fontname{Arial}Up(Without NHC)','\fontname{Arial}\fontname{Arial}East(With NHC)','\fontname{Arial}\fontname{Arial}North(With NHC)','\fontname{Arial}\fontname{Arial}Up(With NHC)'},'FontSize',11);figure('position',[150,100,900,550])%确定图片的位置和大小,[x y width height]
%准备数据
Y1= [127.3,212.5,128.4; 114.7,217.4,125.3;84.7,216.8,124.6;48.9,186.4,117.4;47.8,148.2,118.3;26.9,135.4,121.2]; % withoutNHC
X1=1:6;
%画出4组柱状图,宽度1
h1=bar(X1,Y1,1);
%修改横坐标名称、字体
set(gca,'XTickLabel',{'1','2','3','4','5','6'},'FontSize',10,'FontName','Arial');
% 设置柱子颜色,颜色为RGB三原色,每个值在0~1之间即可
set(h1(1),'FaceColor',[30,150,252]/255)
set(h1(2),'FaceColor',[162,214,249]/255)
set(h1(3),'FaceColor',[252,243,150]/255)
ylim([0,400]); %y轴刻度
%修改x,y轴标签
ylabel('\fontname{Arial}\fontsize{14}Position error(m)');
xlabel('\fontname{Arial}\fontsize{14}The number of groups');
%修改图例
% legend({'\fontname{Arial}例\fontname{Arial}East','\fontname{Arial}例\fontname{Arial}North','\fontname{Arial}例\fontname{Arial}Up'},'FontSize',11);hold on; % 保持当前图形
Y2 = [101.2,4.3,5.4;86.5, 4.4, 5.9;68.5,4.9, 6.1;27.4,4.8,4.1;26.4,2.3,1.4;27.6,5.3,3.6 ]; % withNHC
X2=1:6;
h2=bar(X2,Y2,1);
set(h2(1),'FaceColor',[30,120,252]/255)
set(h2(2),'FaceColor',[122,214,249]/255)
set(h2(3),'FaceColor',[252,243,100]/255)
ylim([0,400]); %y轴刻度
ylabel('\fontname{Arial}\fontsize{14}Position error(m)');
xlabel('\fontname{Arial}\fontsize{14}The number of groups');
legend({'\fontname{Arial}\fontname{Arial}East(Without NHC)','\fontname{Arial}\fontname{Arial}North(Without NHC)','\fontname{Arial}\fontname{Arial}Up(Without NHC)','\fontname{Arial}\fontname{Arial}East(With NHC)','\fontname{Arial}\fontname{Arial}North(With NHC)','\fontname{Arial}\fontname{Arial}Up(With NHC)'},'FontSize',11);
二、效果