91

我想做的就是使宽度更大,高度更小。我只是在做光栅图,但这个问题适用于任何 MATLAB figure。我可以在创建图形时直接使用图形手动调整它的大小,但我希望程序以正确的大小将其吐出。

4

5 回答 5

81

这里figure引用了可以为 a 设置的属性。

然后你可以使用:

figure_number = 1;
x      = 0;   % Screen position
y      = 0;   % Screen position
width  = 600; % Width of figure
height = 400; % Height of figure (by default in pixels)

figure(figure_number, 'Position', [x y width height]);
于 2011-03-03T15:52:08.177 回答
66

Write it as a one-liner:

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

enter image description here

于 2014-08-18T13:15:08.587 回答
31
 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

这会将图形保存在指定的尺寸中

于 2012-12-28T11:06:54.340 回答
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');
于 2016-02-17T13:06:35.033 回答
0

一种不同的方法。
figure()调用后指定属性或修改图形句柄属性h = figure()

这将创建一个基于标准化单位的全屏图形。
figure('units','normalized','outerposition',[0 0 1 1])

units属性可以调整为英寸、厘米、像素等。

请参阅figure 文档

于 2018-10-31T16:29:25.343 回答