首页 文章

设置图形图形大小

提问于
浏览
81

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

5 回答

  • 80

    把它写成 one-liner

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

    enter image description here

  • 29

    A different approach.figure() 调用指定属性或修改 h = figure() 之后的图形句柄属性 .

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

    units 属性可以调整为英寸,厘米,像素等 .

    figure documentation .

  • 56

    This可能对你有帮助吗?

    hFig = figure(1);
    set(hFig, 'Position', [x y width height])
    
  • 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');
    
  • 0
    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
    

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

相关问题