ring (annulis) patch?
이전 댓글 표시
Dear friends,
How do I make a 2D ring (annulus) patch? Is it possible to make it as a single patch with a single object handle?
I want plot several 2D objects in a figure. The objects behind the ring should be visible trough the hole, and I want to control the properties of the ring, e.g. with respect to transperancy, color and line style.
Sincerely, Peter.
채택된 답변
추가 답변 (2개)
Matt Tearle
2011년 3월 20일
How's this? The patch is a single object, but you have to add the edge lines separately in this approach (otherwise you see the "branch cut" in the annulus).
% Make a plot to add the ring to
x = rand(100,1);
y = rand(100,1);
plot(x,y,'o')
% Make inner and outer boundaries
t = linspace(0,2*pi);
rin = 0.1;
rout = 0.25;
xin = 0.5 + rin*cos(t);
xout = 0.5 + rout*cos(t);
yin = 0.5 + rin*sin(t);
yout = 0.5 + rout*sin(t);
% Make patch
hp = patch([xout,xin],[yout,yin],'g','linestyle','none','facealpha',0.25);
hl1 = line(xin,yin,'color','k');
hl2 = line(xout,yout,'color','k');
댓글 수: 6
Peter
2011년 3월 20일
Walter Roberson
2011년 3월 20일
Try putting a NaN between xout and xin, and between yout and yin.
Peter
2011년 3월 20일
Walter Roberson
2011년 3월 21일
I suspect this is due to the face color interpolation method that is set, especially with the leading nan (which you do not need, but a trailing nan might not hurt.) I cannot test out my speculations at the moment as I do not have graphic access right now.
Matt Tearle
2011년 3월 21일
Yes, I thought of trying it with NaN, but that seems to confuse patch -- I think it's unable to work out where the "inside" of the region is. But I feel like a total idiot for not using the same trick for the boundary line.
Anyway, Peter, what's still missing/lacking from this approach? What do you mean by "pure hollow patches"?
Peter
2011년 3월 21일
Sean de Wolski
2011년 3월 19일
0 개 추천
2d or 3d?
For the 2d case just subtract circles. Learn how to make circles here: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F
You could use the same logic for the 3d "donut" using a formula found on wikipedia.
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!