2

我用matlab创建了一些图形,并通过设置“保留信息(如果可能的话)”使用“编辑->复制图形”来导出它们。我在 Word 2010 中导入它。但是,如果我将 word 文档转换为“另存为 pdf”,则数字会有伪影。

下图给你一个印象。左边是放大 400% 的 Word,右边是放大 400% 的 pdf。可以清楚地看到虚线变成直线等。我怎样才能避免这种情况?

在此处输入图像描述

4

3 回答 3

2

扩展 am304 给出的答案 - 我刚刚测试了以下内容:

figure
% create a plot with some fine detail:
plot(sin(1./linspace(0.02, 1, 1000)));
% set the "paper size" of the figure (not the size on screen) to 30x20 cm:
set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 30 20]);
% "print" to png with a resolution of 300 dpi
print('-dpng', 'myplot.png', '-r300');

这会导致将以下图片保存到磁盘(裁剪以仅显示细节): 在此处输入图像描述

全尺寸图片只有 43 kB - 但它是一个非常高分辨率 (300 dpi) 的渲染,因此您可以看到情节的精细细节。

我可以将此图片插入 Word 文档并将其保存为 pdf。然后,当我截取 pdf 的屏幕截图时,它看起来像这样:

在此处输入图像描述

正如你所看到的 - 细节几乎都在那里。

于 2013-09-16T17:21:43.390 回答
1

您可以使用该print功能将图形导出为各种格式。EPS 或 TIFF 应该会产生良好的结果。如果您想要高质量的图形,我不会使用“编辑-> 复制图形”。

于 2013-09-16T15:34:25.117 回答
0

我使用这里的评论来创建自己的方法(还借助:如何将 matlab 中的绘图设置为特定大小?)。所以这是我的功能:

function figureprint(hFig, width, height, res, filename)

%# figure size printed on paper
set(hFig, 'PaperUnits','centimeters')
set(hFig, 'PaperSize',[width height])
set(hFig, 'PaperPosition',[0 0 width height])
set(hFig, 'PaperOrientation','portrait')

%# export
print(hFig, '-dpng', res, filename)

此功能将图形打印到以厘米为单位的特定尺寸。例如

 figureprint(hFig, 12, 10, '-r1500', 'testPng.png')

所以“hFig”被保存为*.png,宽12cm,高10cm。我测量了这个,效果很好。优化当然是可能的。

如果你使用

set(gca,'LooseInset', get(gca,'TightInset'))

y 值的乘法因子的指数被截断(当绘制大数字时)(见图)。在这种情况下,您必须修改值,例如:

tight = get(gca,'TightInset');
tight(1,4) = 0.08;
set(gca,'LooseInset',tight)

在此处输入图像描述

于 2013-09-17T09:28:37.060 回答