2011-03-03 199 views
74

我想要做的就是讓寬度更大,高度更小。我只是在做光柵圖,但這個問題適用於任何MATLAB figure。我可以在創建時直接使用圖形來手動調整它的大小,但我希望程序以合適的大小將其吐出,以便開始。設置圖形圖尺寸

回答

78

This可能可以幫到你嗎?

hFig = figure(1); 
set(hFig, 'Position', [x y width height]) 
+0

那麼發現,我沒有看到那:)。謝謝。 – ale 2011-03-03 16:06:01

+11

如何用'set'定義相同尺寸的圖形?由於saveas(gcf,file,'png')'使用默認尺寸。 – 2012-03-13 12:39:22

+0

@IstvánZachar查看https://stackoverflow.com/questions/3600945/printing-a-matlab-plot-in-exact-dimensions-on-paper/3601094#3601094 – 2015-03-27 15:18:39

28
figure (1) 
hFig = figure(1); 
set(gcf,'PaperPositionMode','auto') 
set(hFig, 'Position', [0 0 xwidth ywidth]) 
plot(x,y) 
print -depsc2 correlation.eps;  % for saving in eps, look up options for saving as png or other formats you may need 

這節省尺寸圖中指定

+6

+ 1爲'PaperPositionMode'它是必要的你想'打印'(導出)這個數字。 – Ali 2013-01-04 12:50:56

50

寫入它作爲一個單行

figure('position', [0, 0, 200, 500]) % create new figure with specified size 

enter image description here

1

我設法用以下順序得到好結果(在開頭運行Matlab兩次):

h = gcf; % Current figure handle 
set(h,'Resize','off'); 
set(h,'PaperPositionMode','manual'); 
set(h,'PaperPosition',[0 0 9 6]); 
set(h,'PaperUnits','centimeters'); 
set(h,'PaperSize',[9 6]); % IEEE columnwidth = 9cm 
set(h,'Position',[0 0 9 6]); 
% xpos, ypos must be set 
txlabel = text(xpos,ypos,'$$[\mathrm{min}]$$','Interpreter','latex','FontSize',9); 

% Dump colored encapsulated PostScript 
print('-depsc2','-loose', 'signals');