【问题标题】:Setting graph figure size设置图形大小
【发布时间】:2011-07-08 04:05:48
【问题描述】:

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

【问题讨论】:

    标签: matlab matlab-figure


    【解决方案1】:

    可以为figure 设置的属性引用here

    然后你可以使用:

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

    【讨论】:

    【解决方案2】:
     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
    

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

    【讨论】:

    • +1 表示“PaperPositionMode”,您需要“打印”(导出)图形。
    【解决方案3】:

    把它写成单行

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

    【讨论】:

      【解决方案4】:

      我设法通过以下顺序获得了一个很好的结果(在开始时运行两次 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');
      

      【讨论】:

        【解决方案5】:

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

        这会根据标准化单位创建一个全屏图形。
        figure('units','normalized','outerposition',[0 0 1 1])

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

        figuredocumentation

        【讨论】:

          猜你喜欢
          • 2018-04-25
          • 1970-01-01
          • 2016-11-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多