How can I print small circles?

조회 수: 1 (최근 30일)
Caglar
Caglar 2018년 10월 30일
편집: Caglar 2018년 11월 1일
Problem I am trying to print small (diameter=0.02 cm etc) filled circles to pdf in exact size. I am able to print exact circles with a diameter of 2 cm, 1 cm, 0.5 cm, but when I try to go below ~0.04 cm, printed figure does not include all circles. Let me show you what I mean with some sample pictures. Note that all circles are separated by their diameter length to obtain a nice stack of them. First image shows the output of same code with d=1, second is d=0.5 and final one is d=0.02.
First two images are correct. In the last image, you can see the most circles are not printed. Circles are in correct size but only a few of them are printed. It had to look stacked like first two, but only in smaller circles.
Codes:
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')
Notes:
-I tried up scaling everything, thinking that I would downscale while printing but it still failed, may be its about ratio of circle to drawing dimensions.
-I hand checked x, y positions, they are correct
-I tried changing marker to '.' but '.' cannot be less than ~2.5 mms even if you give MarkerSize as eps.
-I tried rectangle but it cannot be vectorized therefor its slow and causes too much ram and file size.
-I tried setting figure position to real size, output did not change.
-Output file dimensions are correct in all cases.
-I tried scatter but I simply could not get the real size I wanted from scatter. It says S (marker area) is points^2 in docs for scatter but I could not get any size, for instance d=1cm with scatter circles.
-Behaviour is same on Matlab Online.

답변 (1개)

KSSV
KSSV 2018년 10월 30일
편집: KSSV 2018년 10월 30일
dx = 0.25 ; % spacing in x
dy = 0.25 ; % spacing in y
x = 0:dx:1 ;
y = 0:dy:1 ;
[X,Y] = meshgrid(x,y) ; % generate mesh
% draw circle
th = linspace(0,2*pi) ;
r = 0.1 ; % radius of circle
xc = r*cos(th) ; yc = r*sin(th) ;
figure
hold on
for i = 1:size(X,1)
for j = 1:size(X,2)
x = X(i,j)+xc ;
y = Y(i,j)+yc ;
patch(x,y,'b')
end
end
plot(X,Y,'.r')
  댓글 수: 3
KSSV
KSSV 2018년 10월 31일
If it only dots....why don't you go for plot()/scatter() here..specify the marker and markersize..simple.
Caglar
Caglar 2018년 10월 31일
편집: Caglar 2018년 11월 1일
Hello, as I said in the main post, plot does work for markersizes smaller than 0.04 cm. But when you try to print smaller dots, it skips most of the dots in output. Thats what I need help for.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by