how to draw circle with different radii in scatter plot?
14 次查看(过去 30 天)
显示 更早的评论
I am having three points on scatter plot. taking that point as centre of three circle and draw circles that intercepts each other. please help me its urgent
0 个评论
回答(2 个)
Walter Roberson
2016-3-30
See viscircles() instead if you have a newer version of the Image Processing toolkit. Otherwise,
scatter(x(:), y(:), radii(:).^2)
Actually, converting radii to particular size on the screen is more complicated than that, especially if you need something that stays stable when you resize. Markers in scatter plot are designed to stay the same size when you resize the figure. scatter() really isn't suited for what you are doing. Use viscircles instead. Or rectangle()
0 个评论
Roger Stafford
2016-3-30
Let P1 = [x1,y1], P2 = (x2,y2), and P3 = [x3,y3] be your three points. Then, interpreting your word 'intercepts' as meaning that the circles should be tangent to one another, do this:
a = norm(P2-P3); b = norm(P3-P1); c = norm(P1-P2);
r1 = (b+c-a)/2; r2 = (c+a-b)/2; r3 = (a+b-c)/2; % <-- This produces tangency
t = linspace(0,2*pi,500);
X1 = P1(1)+r1*cos(t); Y1 = P1(2)+r1*sin(t);
X2 = P2(1)+r2*cos(t); Y2 = P2(2)+r2*sin(t);
X3 = P3(1)+r3*cos(t); Y3 = P3(2)+r3*sin(t);
plot(X1,Y1,'y-',X2,Y2,'r-',X3,Y3,'b-', ...
P1(1),P1(2),'yo',P2(1),P2(2),'ro',P3(1),P3(2),'bo')
axis equal
3 个评论
Roger Stafford
2016-3-30
The a, b, and c quantities are the three distances between the points. The formulas you see for r1, r2, and r3 are the necessary radii that will make all three circles of those respective radii tangent to one another. For example, r1+r2 is equal to c which is just the distance between points P1 and P2, thus producing tangency in the two circles about these two points. The remaining lines of code are a standard way of plotting circles with given centers and radii.
If you want the circles to intersect in more than a single point of tangency, then you need to increase each of these radii. It's up to you how much you want such an increase to be.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!