2011-03-03 160 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');