DescTools (version 0.99.15)

DrawCircle: Draw a Circle

Description

Draw one or several circle on an existing plot.

Usage

DrawCircle(x = 0, y = x, radius = 1, rot = 0, nv = 100, 
           border = par("fg"), col = par("bg"), lty = par("lty"), 
           lwd = par("lwd"), plot = TRUE)

Arguments

x, y
a vector (or scalar) of xy-coordinates for the center(s) of the circle(s).
radius
a scalar or a vector giving the radius of the circle(s)
rot
rotation angle for the geometric structure in radiants.
nv
number of vertices to draw the circle.
border
color for annulus borders. The default is par("fg"). Use border = NA to omit borders.
col
color(s) to fill or shade the circle(s) with. The default NA (or also NULL) means do not fill, i.e., draw transparent rectangles, unless density is specified.
lty
line type for borders and shading; defaults to "solid".
lwd
line width for borders and shading.
plot
logical. If TRUE the structure will be plotted. If FALSE only the points are calculated and returned. Use this option if you want to combine several geometric structures to a polygon.

Value

  • The function invisibly returns a list of the calculated coordinates for all shapes.

Details

All geometric arguments will be recycled.

See Also

polygon, DrawRegPolygon, DrawEllipse, DrawArc, DrawAnnulus

Examples

Run this code
Canvas(xlim=c(-5,5))
DrawCircle( radius=4:1, col=c("white","steelblue2","white","red"), lwd=3, nv=300)


x <- seq(-3,3, length.out=18)

par(bg="black")
plot( x=c(-5,5), y=c(-5,5), asp=1, type="n", xaxt="n", yaxt="n", xlab="", ylab="")

sapply( (0:12) * pi/6, function(theta) {
  xy <- Rotate( x, y=0, theta=theta )
  DrawCircle( x=xy$x, y=xy$y, radius=2.4, border="white", col="transparent" )
} )


Canvas(bg="lightgrey", main="Yin ~ Yang")
DrawCircle(col="white")
clip(0, 2, 2, -2)
DrawCircle(col="black")
clip(-2, 2, 2, -2)
DrawCircle(y = c(-0.5,0.5), radius = 0.5, col=c("black","white"), border=NA)
DrawCircle(y = c(-0.5,0.5), radius = 0.1, col=c("white","black"), border=NA)
DrawCircle(col=NA)

Run the code above in your browser using DataCamp Workspace