How can I print small circles?
4 ビュー (過去 30 日間)
古いコメントを表示
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/192967/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/192968/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/192970/image.jpeg)
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.
0 件のコメント
回答 (1 件)
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
2018 年 10 月 31 日
If it only dots....why don't you go for plot()/scatter() here..specify the marker and markersize..simple.
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!