Learn R Programming

shotGroups (version 0.8.2)

drawCircle: Draw a circle

Description

Adds a circle to an existing plot.

Usage

drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA,
           colCtr = NA, lty = par('lty'), lwd = par('lwd'),
           pch = par('pch'), cex = par('cex'))

# S3 method for list drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))

# S3 method for default drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))

Arguments

x

either a numerical vector giving the center's (x,y)-coordinates or a list with the components ctr and rad as returned by getMinCircle.

radius

a numerical vector giving the circle's radius.

nv

number of vertices in the approximating polygon.

fg

color of the circle's rim.

bg

the circle's fill color. Set to NA for a fully transparent circle.

colCtr

color of the center point. Set to NA to omit.

lty

line type of the circle.

lwd

line width of the circle.

pch

symbol used for the center of the circle.

cex

magnification factor for the symbol used for the center of the circle.

Details

This function is mainly a wrapper for polygon. To draw more than a few circles efficiently, use symbols instead.

See Also

polygon, symbols, getMinCircle

Examples

Run this code
c1 <- c(1, 2)                 # circle center
c2 <- c(2, 3)                 # another circle center
r1 <- 2                       # circle radius
r2 <- 0.5                     # another circle radius

# determine axis limits so that circles will be visible
xLims <- c1[1] + c(-r1, r1)
yLims <- c1[2] + c(-r1, r1)

plot(c1[1], c1[2], type='n', asp=1, xlim=xLims, ylim=yLims)
drawCircle(c1, r1, fg='blue', colCtr='blue', pch=19)
drawCircle(c2, r2, fg='red', bg='red', colCtr='black', pch=4)

Run the code above in your browser using DataLab