In Matlab you can draw a circle by just specifying the center and the radius like this:
R = 10;
Center = [5,8];
circle(Center,R,1000,'b-');
hold on
plot(Center(1),Center(2),'g.')
The same code for MatLab won't work for GNU Octave. What octave code would draw a circle given a center x,y coordinates and a radius?
There is no direct function in R to draw a circle but we can make use of plotrix package for this purpose. The plotrix package has a function called draw. cirlce which is can be used to draw a circle but we first need to draw a plot in base R then pass the correct arguments in draw. circle.
t = linspace(0,2*pi,100)';
circsx = r.*cos(t) + x;
circsy = r.*sin(t) + y;
plot(circsx,circsy);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With