2014-10-29 79 views
1

我有一些軸的Gui。 現在我將把一個軸放到一個新的數字上。 這裏是我的代碼:Matlab的GUI軸圖

h = handles.axes3; % Find the axes object in the GUI 
f1 = figure % Open a new figure with handle f1 
s = copyobj(h,f1); % Copy axes object h into figure f1 
print(f1,'-dpsc', 'raspberry.eps'); 

這工作,但窗口沒有大小與數字相同。 我認爲GUI中的軸不在新圖中的axes1上?

回答

1

您複製了軸,而不是圖。

創建一個新圖形將創建一個默認大小 - 這與handle.axes3的祖先(figure)的大小並不相同。

見下面的例子:

f = figure ('position', [100 100 200 200]); 
h = axes ('position', [0 0 0.5 0.5], 'parent', f); 

% This will create a figure with a different size 
f1 = figure ('Name', 'Different Size Fig'); 
copyobj (h, f1); 

% copy a figure which has the same size as the original 
hFig = ancestor (h, 'figure'); 
originalFigPos = get (hFig, 'position'); 
f2 = figure ('Name', 'Same Size Fig'); 
newFigPos = get (f2, 'position'); 
newFigPos(3:4) = originalFigPos(3:4); 
set (f2, 'position', newFigPos); 

s = copyobj (h, f2);