how to keep parent figure settings after inserting children figures
이전 댓글 표시
I want to create a figure which looks like a subplot (1,3,1-3) but without any space between subplots to compare observed and modeled observations. I've set parent/children figures using a code below:
%%Figure settings
figW = 7.5; % parent figure width
figH = 5.9; % parent figure height
lM = .75; % left margin
rM = .25; % right margin
bM = .75; % bottom margin
tM = .25; % top margin
W = (figW-lM-rM)/3; % width of a subplot
H = (figH-tM-bM); % height of a subplot
axLW = 1.0; % line width
fontS = 8;
fontN = 'Helvetica';
%%Axes
fig_h = figure('Color','w','Units','inches','Position',[0 0 figW figH],...
'PaperOrientation','landscape','PaperSize',[figW figH],'PaperPosition',[0 0 figW figH/figW]);
movegui(fig_h,'center');
ax_1 = axes('Parent',fig_h,'Position',[lM/figW bM/figH W/figW H/figW],...
'Box','on','LineWidth',axLW,'FontSize',fontS,'FontName',fontN);
ax_2 = axes('Parent',fig_h,'Position',[(lM+W)/figW bM/figH W/figW H/figW],...
'Box','on','LineWidth',axLW,'FontSize',fontS,'FontName',fontN);
ax_3 = axes('Parent',fig_h,'Position',[(lM+2*W)/figW bM/figH W/figW H/figW],...
'Box','on','LineWidth',axLW,'FontSize',fontS,'FontName',fontN);
%%Axes settings
set(get(ax_1,'YLabel'),'String','Measured pCO_2 [\muatm]',...
'FontSize',fontS,'FontName',fontN);
set(get(ax_1,'XLabel'),'String','Calculated pCO_2 (pH-DIC) [\muatm]',...
'FontSize',fontS,'FontName',fontN);
set(get(ax_2,'XLabel'),'String','Calculated pCO_2 (pH-ALK) [\muatm]',...
'FontSize',fontS,'FontName',fontN);
set(get(ax_3,'XLabel'),'String','Calculated pCO_2 (ALK-DIC) [\muatm]',...
'FontSize',fontS,'FontName',fontN);
%%Figure limits
max2 = max([pco2b_pal;pco2s_pal;pco2h_pal]);
max3 = max([pco2b_dal;pco2s_dal;pco2h_dal]);
set(ax_1,'XLim',[0 4000],'YLim', [0 3000], 'XTick',1000:1000:3500, 'XTickLabel',{'1000';'2000';'3000'},...
'YTick',500:1000:3000,'YTickLabel',{'500';'1500';'2500'});
set(ax_2,'Xlim',[0 13000],'YLim',[0 3000],...
'XTick',4000:4000:max2,'XTickLabel',{'4000';'8000';'12000'},'YTick',500:1000:3000,'YTickLabel','');
set(ax_3,'Xlim',[0 7000],'YLim',[0 3000],...
'XTick',2000:2000:max3, 'XTickLabel',{'2000';'4000';'6000'},'YTick',500:1000:3000,'YTickLabel','');
The figure looks like that:

But after adding 1:1 line to a child figure 1 using code lines:
%%1:1 Line
xl = (0:1500:3000);
yl = (0:1500:3000);
%%Plot 1 in a parent figure
p1 = plot(xl,yl,'k'); %1:1 line
set(p1,'Parent', ax_1,'Linewidth',1)
the plot looks like that:

My problem is that I don't know how to keep parent figure settings after inserting children figures? Do you know why subplot 3 changes when I insert the line to subplot 1?
Thanks, Gosia
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!