## plotting circles

### Yasmine Tamimi (view profile)

on 12 Mar 2011
Latest activity Commented on by Image Analyst

### Image Analyst (view profile)

on 29 Jan 2016 at 16:52

### Paulo Silva (view profile)

How can I plot circles, same radius and different centers, all in one graph. I used the following command to draw +,o,diamond: plot (x,y,'ro',u,v,'gd',A,B,'b+'); where x,y,u,v,A,B are all row vectors. And I want to add circles to that plot where the o will be the center.

## Products

### Paulo Silva (view profile)

on 12 Mar 2011

Here's a function to draw circles:

```function circle(x,y,r)
%x and y are the coordinates of the center of the circle
%r is the radius of the circle
%0.01 is the angle step, bigger values will draw the circle faster but
%you might notice imperfections (not very smooth)
ang=0:0.01:2*pi;
xp=r*cos(ang);
yp=r*sin(ang);
plot(x+xp,y+yp);
end
```

If you want to add circles you must insert the command

```hold on
```

Firas

on 29 Dec 2014

That's awesome

### Michelle Hirsch (view profile)

on 29 Jan 2016 at 14:48

It's counter-intuitive, but this is actually really easy with the rectangle function. From the rectangle documentation :

```   pos = [2 4 2 2];
rectangle('Position',pos,'Curvature',[1 1])
axis equal```

Image Analyst

### Image Analyst (view profile)

on 29 Jan 2016 at 16:52

And with R2012a and later you can use viscircles

### Image Analyst (view profile)

on 5 Jul 2012

on 21 Aug 2014

This'll do the job.

### Image Analyst (view profile)

on 20 Jan 2016 at 19:41