如何在MATLAB中打印小圆圈?

Vol*_*can 5 matlab pdf-generation matlab-figure

问题我正在尝试将小圆(直径= 0.02厘米等)实心圆圈打印成精确尺寸的pdf.我可以打印直径为2厘米,1厘米,0.5厘米的精确圆圈,但是当我试图低于~0.04厘米时,打印的图形不包括所有圆圈.让我告诉你我对一些样本图片的意思.请注意,所有圆圈都以它们的直径长度分隔,以获得它们的良好堆叠.第一幅图显示了相同代码的输出,其中d = 1,第二幅是d = 0.5,最后一幅是d = 0.02.

d =1厘米

d =0.5厘米

d = 0.02厘米

前两张图片是正确的.在最后一张图片中,您可以看到大多数圆圈未打印.圆圈尺寸正确,但只有少数印刷.它必须看起来像前两张图片,但只有较小的圆圈.

最低工作示例代码:

cm2pts=72/2.54; %cm to inch and inch to points = cm to points
ax.Units='points'; fig.Units='points';
height=cm2pts*220; % 'page' dimensions
width=cm2pts*150;
ax.XLim=([0 width]); ax.XLim=([0 height]);
diameter=0.02*cm2pts;
distance=diameter;
...
here is a loop that creates a x,y position vector for all dots
...
plot(ax,x,y, ... 'MarkerFaceColor','black','MarkerEdgeColor','none', ...
'Marker','o','LineStyle','none','MarkerSize',diameter);
set(ax,'xtick',[],'ytick',[]);
ax.Units='normalized'; ax.Position=[0 0 1 1]; ax.Units='points';
fig.PaperUnits='points';
fig.PaperPositionMode = 'manual';
fig.PaperPosition=[0 0 width height];
fig.PaperSize = [PaperPosition(3) PaperPosition(4)];
print(fig,'-painters','output.pdf','-dpdf')
Run Code Online (Sandbox Code Playgroud)

笔记

- 我尝试缩放所有内容(以5倍大小打印,以便圆圈更大),认为我会在打印时缩小(降至20%),但仍然失败,可能是它与圆形与绘图尺寸的比例.

- 我手检查x,y位置,它们是正确的.

- 我尝试将标记更改为'.' 但是'.' 即使你将MarkerSize作为eps,也不能小于~2.5毫米.

- 我试过矩形,但它无法进行矢量化(通过代码),因此它很慢并导致太多的ram和文件大小.

- 我尝试将图形位置设置为实际尺寸,输出没有变化.

- 输出文件尺寸在所有情况下都是正确的.

- 我试过分散,但我根本无法从散射中得到我想要的真实尺寸.它表示S(标记区域)是分散文档中的点^ 2但是我无法获得任何大小,例如,d 1cm带有散射圆.

-Behaviour在Matlab Online上是一样的.

rin*_*ert 1

我用于 Matlab R2018b 的代码,输出包含所有所需点的 pfd。

fig = figure;
ax = axes;

cm2pts=72/2.54; %cm to inch and inch to points = cm to points
ax.Units='points'; fig.Units='points';
height=cm2pts*220; % 'page' dimensions
width=cm2pts*150;
ax.XLim=([0 width]); ax.XLim=([0 height]);
diameter=0.01*cm2pts;
distance=diameter;

% generate 100 by 100 dots
X = 1:100;
[x,y] = meshgrid(X,X);


% plotting
plot(ax,x,y, 'MarkerFaceColor','black','MarkerEdgeColor','none', ...
    'Marker','o','LineStyle','none','MarkerSize',diameter);

set(ax,'xtick',[],'ytick',[]);
ax.Units='normalized'; ax.Position=[0 0 1 1]; ax.Units='points';
fig.PaperUnits='points';
fig.PaperPositionMode = 'manual';
fig.PaperPosition=[ 0 0 width height];
fig.PaperSize = [fig.PaperPosition(3) fig.PaperPosition(4)];
print(fig,'-painters','output.pdf','-dpdf')
Run Code Online (Sandbox Code Playgroud)