how to draw circle with different radii in scatter plot?
21 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Walter Roberson
on 30 Mar 2016
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 Comments
Roger Stafford
on 30 Mar 2016
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 Comments
Roger Stafford
on 30 Mar 2016
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.
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!