Copying existing .fig files into Panel
조회 수: 1 (최근 30일)
이전 댓글 표시
I'd like to use Panel from the File Exchange instead of subplot so I can have more control over the margins between subplot figures. I have a number of existing Matlab .fig files I'd like to put in a grid.
However, when I use copyobj to copy the children from a .fig file into an existing panel ( p = panel() ), I get the resulting error:
fig1 = openfig(char('file.fig'), 'reuse');
>> copyobj(allchild(get(fig1, 'CurrentAxes')), p(1,1));
Error using copyobj
Line cannot be a child of panel.
This method also results in an error:
>> fig1 = get(fig1_gca, 'children');
>> copyobj(fig1, p(1, 1))
Error using copyobj
Axes cannot be a child of panel.
Is there a better way to open existing .fig files and copy them into Panel?
댓글 수: 0
답변 (1개)
Max Murphy
2019년 11월 11일
Sorry if this answer is too late to help you, but it looks like in your examples above you were trying to copy children of an axes object into a panel. In your first example, you could copy the axes (fig1_gca, from second example) into the panel p(1,1), or you could create a new axes in p(1,1) and copy the children of fig1_gca into that axes.
I had a similar question and this was my solution:
oldFigFiles = {'oldFig1.fig'; 'oldFig2.fig'};
nOldFig = numel(oldFigFiles);
newFig = figure('Name','oldFig contents in tabs');
tg = uitabgroup(newFig);
t = gobjects(nOldFig,1);
p = gobjects(nOldFig,1);
for i = 1:nOldFig
oldFig = openfig(oldFigFiles{i});
c = get(oldFig,'Children');
% Move contents of oldFig into current tab
t(i) = uitab(tg,'Title',oldFigFiles{i});
p(i) = uipanel(t(i));
copyobj(c,p(i));
delete(oldFig); % close old figure
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!