Setting graph figure size

自作多情 提交于 2019-11-26 11:58:33

问题


All I want to do is make the width greater and the height smaller. I\'m just doing raster plots but this question applies to any MATLAB figure. I can manually resize it using the figure directly when it\'s created but I want the program to spit it out in the right size to start with.


回答1:


This could possibly help you?

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



回答2:


Write it as a one-liner:

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




回答3:


 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

This saves the figure in the dimensions specified




回答4:


I managed to get a good result with the following sequence (run Matlab twice at the beginning):

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');



回答5:


A different approach.
On the figure() call specify properties or modify the figure handle properties after h = figure().

This creates a full screen figure based on normalized units.
figure('units','normalized','outerposition',[0 0 1 1])

The units property can be adjusted to inches, centimeters, pixels, etc.

See figure documentation.



来源:https://stackoverflow.com/questions/5183047/setting-graph-figure-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!