How to plot two .fig file as subplots in a new figure window ?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to create a single figure window conataining both the .fig files as subplots. Help is deeply appreciated.
0 Kommentare
Akzeptierte Antwort
Jonas
am 12 Dez. 2022
h(1) = openfig('fog.fig','invisible');
ax(1)=gca;
h(2) = openfig('snow.fig','invisible');
ax(2)=gca;
N=numel(h);
figure;
for i=1:N
% create and get handle to the subplot axes
s(i) = subplot(N,1,i);
% get handle to all the children in the figure
aux=get(ax(i),'children');
for j=1:size(aux)
fig(i) = aux(j);
copyobj(fig(i),s(i));
hold on
end
% copy children to new parent axes i.e. the subplot axes
xlab = get(get(ax(i),'xlabel'),'string');
xlabFontSize= get(get(ax(i),'xlabel'),'FontSize');
xlabInterpreter = get(get(ax(i),'xlabel'),'Interpreter');
ylab = get(get(ax(i),'ylabel'),'string');
ylabFontSize = get(get(ax(i),'ylabel'),'FontSize');
ylabInterpreter = get(get(ax(i),'ylabel'),'Interpreter');
tit = get(get(ax(i),'title'),'string');
titFontSize = get(get(ax(i),'title'),'FontSize');
titInterpreter = get(get(ax(i),'title'),'Interpreter');
hasLegend=~isempty(findobj(h(i),'type','legend'));
if hasLegend
lgText = get(get(ax(i),'legend'),'string');
lgLocation = get(get(ax(i),'legend'),'Location');
end
xLimits = get(ax(i),'XLim');
yLimits = get(ax(i),'YLim');
xGrid = get(ax(i),'XGrid');
yGrid = get(ax(i),'YGrid');
ScaleX = get(ax(i),'Xscale');
ScaleY = get(ax(i),'Yscale');
TickX = get(ax(i),'Xtick');
TickY = get(ax(i),'Ytick');
TicklabelX = get(ax(i),'Xticklabel');
TicklabelY = get(ax(i),'Yticklabel');
set(gca, 'XScale', ScaleX, 'YScale', ScaleY, 'Xtick', TickX, 'Ytick',...
TickY, 'Xticklabel', TicklabelX, 'Yticklabel', TicklabelY,'XGrid',xGrid,'YGrid',yGrid);
xlabel(xlab,'FontSize',xlabFontSize,'Interpreter',xlabInterpreter);
ylabel(ylab,'FontSize',ylabFontSize,'Interpreter',ylabInterpreter);
title(tit,'FontSize',titFontSize,'Interpreter',titInterpreter);
xlim(xLimits);
ylim(yLimits);
if hasLegend
legend(lgText,'Location',lgLocation)
end
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!