【问题标题】:Set the dpi for a figure in Matlab在 Matlab 中设置图形的 dpi
【发布时间】:2020-09-20 08:26:15
【问题描述】:

我在数字的 dpi 方面遇到了一个小问题,或者 windows 只是在欺骗我。 我使用以下行打印图像

fig =gcf;
fig.PaperPositionMode = 'auto';
print('ScreenSizeFigure',-djpeg,'-r600');

所以这是根据窗口对结果图像的统计:

  • 尺寸:11900x6169
  • 宽度11900
  • 像素高度 6169 像素
  • 水平分辨率 96 dpi
  • 垂直分辨率 96 dpi

Matlab(我使用的是 Matlab R2019b 更新 6)、我的代码有什么问题,还是 windows 只是给了我错误的信息? 感谢所有帮助。

【问题讨论】:

    标签: matlab figure dpi


    【解决方案1】:

    这在某种程度上是一个已知问题。您可能想尝试另一个 Matlab 函数。 export_fig.m exports figures nicely to a number of vector & bitmap formats

    这里有一些演示: https://github.com/altmany/export_fig/blob/master/README.md

    【讨论】:

      【解决方案2】:

      如果只是单个图形,请使用导出设置的 GUI。

      文件 > 导出设置 ...> 渲染 > 分辨率 (dpi) + 别忘了点击应用到图

      如果您需要以相同的大小/字体/渲染导出多个图形,定义 导出样式 会很方便。一旦你定义了一个,你可以使用这个简单的功能自动加载并应用到你的图形:

      function FigExport(fh,FileName,ExpStyl)
      %%
      ax = get(fh, 'children');
      lg = arrayfun(@(x)isa(x,'matlab.graphics.axis.Axes'),ax);
      if ~all(cellfun(@(x)strcmp(x,'on'),{ax(lg).Box}))
          box(ax(lg),'on')
      end
      
      % get style sheet info
      if nargin < 3 || isempty(ExpStyl)
          ExpStyl = 'PPT'; % The name of your style file (NO extension)
      end
      s = hgexport('readstyle',ExpStyl);
      
      %% apply style sheet info & export file
      if isempty(FileName)
          FileName = 'tmpFigExprt';
      end
      
      s.Format = 'jpeg'; %I needed this to make it work but maybe you wont.
      hgexport(fh,FileName,s);
      end
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-11-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-19
        • 2018-09-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多