Here is a way of plotting the selected points in a different color with ifelse
. Set graphics parameter col
to the values "red"
and "black"
depending on the x axis values.
FSC <- -5:10
RED <- seq_along(FSC)
plot(FSC, RED, col = ifelse(FSC > 0 & FSC < 4, "red", "black"))

Another, equivalent way is to create a vector of colors beforehand. In the code that follows I also change the point character to solid circle, though this is not in the question. And use the data set DAT1
directly without creating new vectors FSC
and RED
.
DAT1 <- data.frame(FSC.HLin = FSC, RED.V.HLin = RED)
col <- with(DAT1, ifelse(FSC.HLin > 0 & FSC.HLin < 4, "red", "black"))
pch <- with(DAT1, ifelse(FSC.HLin > 0 & FSC.HLin < 4, 16, 1))
plot(RED.V.HLin ~ FSC.HLin, data = DAT1, col = col, pch = pch)
