MATLAB--画多组boxplot

分类: MATLAB |
用matlab画两种数据的箱线图对比
该方法其本质为画两张共享横轴的boxplot
% code
position_O = 1:1:12;
% Define position for 12 Month_O
boxplots
box_O =
boxplot(pbl_monthly_cs(:,1:12),'colors','b','positions',position_O,'width',0.18);set(gca,'ylim',[0
2000]);
set(gca,'XTickLabel',{'Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun'
'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec'}) % Erase
xlabels
hold on % Keep the Month_O boxplots on
figure overlap the Month_S
boxplots
% Boxplot for the simulated temperature from January to
December
position_S = 1.3:1:12.3; % Define position
for 12 Month_S boxplots
box_S =
boxplot(pbl_monthly_cs(:,13:24),'colors','r','positions',position_S,'width',0.18);
ylabel('PBLH (m)','Fontname','Times New
Roman','FontWeight','bold','FontSize',font)
set(gca,'XTick', [1 2 3 4 5 6 7 8 9 10 11
12]);set(gca,'ylim',[0 2000]);
set(gca,'XTickLabel',{'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'})
set(gca,'FontSize',font,'FontName','Times New
Roman','FontWeight','bold');
set(gca,'TickDir','out');
% set(gca,'ygrid','on');
set(gca,'FontSize',font,'FontName','Times New
Roman','FontWeight','bold')
text(1,1800,'CS-20:00','FontSize',font,'FontName','Times New
Roman','FontWeight','bold')