Happy new year to you all!
I am plotting some graphs and would like to differentiate some plotted lines and points. This is an example of my data and the graph that I am trying to get:
anim <- c(1,2,3,4,5)
var1 <- c(32,36,40,38,39)
var2 <- c(30,31,34,36,38)
surv <- c(0,1,0,1,1)
mydf <- data.frame(anim,var1,var2,surv)
mydf
anim var1 var2 surv
1 1 32 30 0
2 2 36 31 1
3 3 40 34 0
4 4 38 36 1
5 5 39 38 1
lm.pos1 <- lm(var1~var2,data=mydf)
plot(mydf$var2,mydf$var1,xlab="ave.ear",ylab="rtemp",xlim=c(25,45),ylim=c(25,45))
abline(lm.pos1)
abline(h=37.6,v=0,col="gray10",lty=20)
abline(h=34,v=0,col="gray10",lty=20)
First, I would like to insert the label “37.6°C” on the top horizontal and continuous line and “34.0°C” on the bottom horizontal and broken line.
Second, I would like to colour those individuals (circles) as red if surv=0 (died) or green if surv=1.
Any help would be very much appreciated!
Baz
1 Answer