I have a plot where the color of circles (pch=19) at present is either red (when values in conditioning column is >4.5) and black if values are missing (NA).
points(bb$Year,bb$Tot,col=ifelse(bb$rate<4.5|is.na(bb$rate),'black','red'),pch=19,cex=1.7)
I need a third color, or better, an open circle (pch=21) when values are <=4.5.
Probably simple, but a bit tricky to me.
CodePudding user response:
You need to create an index value that codes for symbol and color:
x <- 0:10
y <- (5 - x)^2
z <- 0:10
z[c(3, 9)] <- NA # Conditioning variable
sym <- c(1, 16, 16)
clr <- c("black", "black", "red")
idx <- ifelse(is.na(z), 1, ifelse(z <= 4.5, 2, 3))
plot(x, y, pch=sym[idx], col=clr[idx])