File Exchange

image thumbnail

circle plotter

version 1.1.1 (482 KB) by Chad Greene
Simply plot filled circles or circle outlines.

27 Downloads

Updated 20 May 2019

View License

Adding to the mix of circle plotters on the File Exchange site, this function plots any number of circles of any size and x,y location. Inputs can be any logical mix of scalars, vectors, or N-D arrays. Circles can be easily formatted using LineSpec and ColorSpec name-value pairs.

Syntax
circles(x,y,r)
circles(...,'vertices',numberOfPoints)
circles(...,'rotation',degreesRotation)
circles(...,'ColorProperty',ColorValue)
circles(...,'LineProperty',LineValue)
h = circles(...)

Description
circles(x,y,r) plots circle(s) of radius or radii r centered at points given by x and y. Inputs x, y, and r may be any combination of scalar, vector, or 2D matrix, but dimensions of all nonscalar inputs must agree.

circles(...,'vertices',numberOfPoints) allows specification of how many points to use for the outline of each circle. Default value is 1000, but this may be increased to increase plotting resolution. Or you may specify a small number (e.g. 4 to plot a square, 5 to plot a pentagon, etc.).

circles(...,'rotation',degreesRotation) rotates the shape by a given degreesRotation, which can be a scalar or a matrix. This is useless for circles, but may be desired for polygons with a discernible number of corner points.

circles(...,'ColorProperty',ColorValue) allows declaration of 'facecolor' or 'facealpha' as name-value pairs. Try declaring any fill property as name-value pairs.

circles(...,'LineProperty',LineValue) allows declaration of 'edgecolor', 'linewidth', etc.

h = circles(...) returns the handle(s) h of the plotted object(s).

TIPS:
1. Include the name-value pair 'facecolor','none' to draw outlines (non-filled) circles.

2. Follow the circles command with axis equal to fix distorted circles.

Cite As

Chad Greene (2019). circle plotter (https://www.mathworks.com/matlabcentral/fileexchange/45952-circle-plotter), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

Ryan O'Hara

Very Helpful! Thanks for sharing!

YT

Only accepts 1-by-3 vector for facecolor (not very usefull when you got an array of M-by-3 RGB color values).

Bruce

Really nice bit of code. Any thoughts on how to, in the case of multiple circles, color the circles based on the current colormap and circle radius? It ought to be simple, but I'm having one of my "Friday brain farts".

foboo

soupdegras

MATLAB already has inbuilt circle and ellipse drawing using the |rectangle| function:

http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F

http://www.mathworks.com/help/matlab/ref/rectangle.html

Updates

1.1.1

Added live scripts

1.1.0.0

added rotation feature for non-circles and added example file.

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor