I have the following R code that I am using to plot a set of time series, which are normalised [0,1]
. I want each of the lines to have a color intensity such that all values <= 0.5
have shades of blue and > 0.5
have shades of orange/yellow. This is what I have right now:
data <- SOME_DATA
for(i in 1:length(data)){
y <- data[[paste("I",i,sep = "")]]
x <- 1:length(y)
lo <- loess(y~x)
ylim <- range(seq(-1,1,by=0.5))
if(i==1){
plot(x,y,ylim = ylim,main = "Some title",col = ifelse(y[1] < 0,'red','green'),ylab = "intensity",xlab = "time steps")
}
lines(predict(lo),lwd=2,ylim = ylim,col = ifelse(y[1] < 0,rgb(1,0,0,0.2),rgb(0,1,0,0.2)))
}
How can I go about achieving what I described above?
Thanks