Skip to content
Prev 167635 / 398502 Next

plotting points with two colors

I don't know how efficient you would consider this, but here is one solution:

library(TeachingDemos)

ms.2circ <- function(r=1, adj=0, col1='blue', col2='red', npts=180) {
	tmp1 <- seq( 0,   pi, length.out=npts+1) + adj
	tmp2 <- seq(pi, 2*pi, length.out=npts+1) + adj
	polygon(cos(tmp1)*r,sin(tmp1)*r, border=NA, col=col1)
	polygon(cos(tmp2)*r,sin(tmp2)*r, border=NA, col=col2)
	invisible(NULL)
}

x <- runif(10)
y <- rnorm(10)
a <- runif(10, 0, 2*pi)

my.symbols(x,y, ms.2circ, inches=0.15, add=FALSE, symb.plots=TRUE, adj=a)

# or

my.symbols(x,y, ms.2circ, inches=0.15, add=FALSE, symb.plots=TRUE, adj=a,
	col1="#00ff0088", col2="#ff00ff88")

Hope this helps,