Skip to content
Prev 369782 / 398503 Next

draw stripes in a circle in R

I finally understood the question and it needs a hack to the draw.circle function in plotrix since the angle and density arguments don't get passed in:

First get code for draw.circle:

------

draw.circle   # then copy to console and edit

draw.circle2  <- function (x, y, radius, nv = 100, border = NULL, col = NA, lty = 1, 
                           density=NA, angle=45,  lwd = 1 ) 
{
    xylim <- par("usr")
    plotdim <- par("pin")
    ymult <- getYmult()
    angle.inc <- 2 * pi/nv
    angles <- seq(0, 2 * pi - angle.inc, by = angle.inc)
    if (length(col) < length(radius)) 
        col <- rep(col, length.out = length(radius))
    for (circle in 1:length(radius)) {
        xv <- cos(angles) * radius[circle] + x
        yv <- sin(angles) * radius[circle] * ymult + y
        polygon(xv, yv, border = border, col = col, lty = lty, density=density, angle=angle,
                lwd = lwd)
    }
    invisible(list(x = xv, y = yv))
}

Now run your call to pdf with draw.circle2 instead of draw.circle

Best;
David.
David Winsemius
Alameda, CA, USA