3

我正在尝试制作 Matlab,7.10.0.499(R2010a),使用 eps 写出一个图形,print但无论我将图形设置为何种纸张尺寸,它都会不断裁剪轴标签,除非我将其设为 A3。

这是一个 png 来说明问题(尽管我知道 png 来自不同的渲染管道)。

在此处输入图像描述

生成此图的代码是:

    figure, 
set(gcf, 'renderer', 'painters');

loglog(p_m_tt, p_fa_tt, 'k-', 'LineWidth', 2); hold on;
loglog(p_m_oo, p_fa_oo, 'k--', 'LineWidth', 2); hold on;
loglog(p_m_ot, p_fa_ot, 'k-.', 'LineWidth', 3); hold on;
fontSize = 9;

l = legend('Cam1-Cam1', 'Cam2-Cam2', 'Cam2-Cam1', ...
    'Location', 'NorthEast');

fontSize = 20;
xlabel('$P_{fa}$', 'fontsize', fontSize);
ylabel('$P_{m}$', 'fontsize', fontSize);

set(gca, 'XMinorTick', 'off', 'YMinorTick', 'off', 'YGrid', 'on', 'XGrid', 'on');
set(gcf, 'PaperPositionMode', 'auto');
set(gca, 'XTick', [0.00001 0.0001 0.001 0.01 0.1 1]);
set(gca, 'MinorGridLineStyle', 'none');

set(gca, 'FontSize', fontSize);
set(gcf, 'defaultAxesFontName', 'Times New Roman');

axis square;

X = 13;
Y = 13;
xMargin = 0.25;             %# left/right margins from page borders
yMargin = 0.25;             %# bottom/top margins from page borders
xSize = X - 2*xMargin;      %# figure size on paper (widht & height)
ySize = Y - 2*yMargin; 

set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperSize', [X Y]);
set(gcf, 'PaperPosition', [0 0 xSize ySize]);
print('-depsc2', f);
4

3 回答 3

2

Use the -loose option with print so that matlab doesn't crop it. See the helpfile on print for details.

于 2013-04-08T15:07:53.070 回答
1

我拿了你的代码并运行它(当然,替换变量以绘制虚拟数据)并在 illustrator 中加载 eps,结果很好。你用的是哪个版本的matlab?

另外,为了以防万一,我只是稍微修改了代码,因为它之前不会运行,因为没有定义变量“f”,我包含了代码和我得到的示例:

f=figure;
set(gcf, 'renderer', 'painters'); 

p_m_tt=10e-4*0:0.001:1;
p_m_oo=p_m_tt;
p_m_ot=p_m_oo;
p_fa_tt=rand(size(p_m_tt));
p_fa_oo=rand(size(p_m_tt));
p_fa_ot=rand(size(p_m_tt));
loglog(p_m_tt, p_fa_tt, 'k-', 'LineWidth', 2); hold on; 
loglog(p_m_oo, p_fa_oo, 'k--', 'LineWidth', 2); hold on; 
loglog(p_m_ot, p_fa_ot, 'k-.', 'LineWidth', 3); hold on; 

l = legend('Cam1-Cam1', 'Cam2-Cam2', 'Cam2-Cam1', ... 
    'Location', 'NorthEast'); 

fontSize = 20; 
xlabel('$P_{fa}$', 'fontsize', fontSize); 
ylabel('$P_{m}$', 'fontsize', fontSize); 

set(gca, 'XMinorTick', 'off', 'YMinorTick', 'off', 'YGrid', 'on', 'XGrid', 'on'); 
set(gcf, 'PaperPositionMode', 'auto'); 
set(gca, 'XTick', [0.00001 0.0001 0.001 0.01 0.1 1]); 
set(gca, 'MinorGridLineStyle', 'none'); 

set(gca, 'FontSize', fontSize); 
set(gcf, 'defaultAxesFontName', 'Times New Roman'); 

axis square; 

X = 13; 
Y = 13; 
xMargin = 0.25;             %# left/right margins from page borders 
yMargin = 0.25;             %# bottom/top margins from page borders 
xSize = X - 2*xMargin;      %# figure size on paper (widht & height) 
ySize = Y - 2*yMargin;  

set(gcf, 'PaperUnits', 'centimeters'); 
set(gcf, 'PaperSize', [X Y]); 
set(gcf, 'PaperPosition', [0 0 xSize ySize]); 
print('-depsc2', f,'figure2.eps');

在此处输入图像描述

于 2012-07-10T18:00:29.787 回答
1

除了修改图形PaperPosition,还可以修改轴position属性。可以通过以下方式检索当前设置:

get(gca, 'position')

答案=

0.1300    0.1300    0.7750    0.7750

这些编纂为[left bottom width height]. 然后通过增加前两个数字并减少后两个数字来增加边距:

set(gca, 'position', [.15, .15, .74, .74]);
于 2014-08-13T14:57:01.153 回答