figure(1)
hold on
position1 = 1.1:7.1;
position2 = 1.4:7.4;
b1 = boxplot(peak_lowfs_mean,label,...
'width',2,...
'Color',[1 0.2 0],... %箱体边框及异常点颜色
'PlotStyle','compact',...
'position',position1,...
'MedianStyle','line',...
'Notch','off',...
'OutlierSize',2);
set(b1,'Linewidth',1.5);
lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
set(lines, 'Color', 'none');
%改变第一组箱子的箱宽
a = get(get(gca,'children'),'children'); % Get the handles of all the objects
t = get(a,'tag'); % List the names of all the objects
idx=strcmpi(t,'box'); % Find Box objects
boxes=a(idx); % Get the children you need
set(boxes,'linewidth',10); % Set width
b2 = boxplot(peak_highfs_mean,label,...
'width',2,...
'Color',[0 0.2 1],... %箱体边框及异常点颜色
'PlotStyle','compact',...
'position',position2,...
'MedianStyle','line',...
'Notch','off',...
'OutlierSize',2);
set(b2,'Linewidth',1.5);
lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
set(lines, 'Color', 'none');
%改变第二个箱子的箱宽
b = get(get(gca,'children'),'children'); % Get the handles of all the objects
b = b{1}; % 此时有两组箱子,只改变第二组即可
t = get(b,'tag'); % List the names of all the objects
idx=strcmpi(t,'box'); % Find Box objects
boxes=b(idx); % Get the children you need
set(boxes,'linewidth',10); % Set width
xlim([0.5 8])
ylim([0.5 3.5])
xlabel('{\itf}_s','position',[195.3,-22.25,0],'fontsize',20)
% xlabel('{\itf}_s')
ylabel('Peak counts','fontsize',20)
set(gca, 'XTick',1.25:1:7.25, 'XTickLabel', {'(0,0.1)','(0.1,0.2)','(0.2,0.3)','(0.3,0.4)','(0.4,0.5)','(0.5,1)'},'fontsize',12);
box on
set(gca,'FontSize',12);
set(gca,'Linewidth',1.5);
h = figure(1);
set(h,'units','normalized','position',[0.2 0.1 0.35 0.35]);
修改之前的图:
修改后: