It is possible to change the color following the value of a variable. You can use the ifelse statement for that.
Learn more about color management in R in the dedicated section.
1 2 3 4 5 6 7 8 9 10 |
# Create data data=data.frame( my_x = 1:100 + rnorm(100,sd=9), my_y = 1:100 + rnorm(100,sd=16) ) # Add the plot plot(data$my_x , data$my_y, col=ifelse(data$my_x>50,"red","skyblue") , lwd=3 , xlab="value of X" , ylab="value of Y" ) # Add a vertical line abline(v=50 , col="grey") |
Not what you are looking for ? Make a new search ![mediatagger]
Leave a Reply
Be the First to Comment!