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!