Skip to content
Prev 1732 / 63424 Next

A subroutine for plotting stars

Hello,

I implemented "symbols.stars", a sub routine plotting stars.

It is intended to be called from "symbols".

Please use it if it is acceptable.

Yusuke Uchiyama

Laboratory of Insect Physiology
Graduate School of Agriculture
Kyoto University

e-mail: yusuke@kais.kyoto-u.ac.jp

---cut here---

"symbols.stars" <-
function (x, y, stars, add = FALSE, ...) 
{
    stars <- t(stars)
    i <- dim(stars)[1]
    anstep <- 2 * pi/i
    anstep <- anstep * 0:(i - 1) + pi/2
    dim(anstep) <- length(anstep)
    anstep <- t(apply(anstep, 1, rep, dim(stars)[2]))
    dim(x) <- length(x)
    dim(y) <- length(y)
    x <- apply(x, 1, rep, i)
    y <- apply(y, 1, rep, i)
    x <- x + stars * cos(anstep)
    y <- y + stars * sin(anstep)
    x <- c(apply(x, 2, c, NA))
    y <- c(apply(y, 2, c, NA))
    if (add == FALSE) {
        xlim <- c(min(x[!is.na(x)]) - 1.5, max(x[!is.na(x)]) + 
            1.5)
        ylim <- c(min(y[!is.na(y)]) - 1.5, max(y[!is.na(y)]) + 
            1.5)
        plot.new()
        plot.window(xlim, ylim)
    }
    polygon(x, y)
}





-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._