I'm trying to create a scatter plot with fitted linear models and log scale axes, but it is causing my model lines to disappear and I can't figure out why.
My data looks like:
Environment Min_light_reqs Leaf_lifespan
1 Shade 1.4 3.5
2 Shade 3.48 0.7
3 Shade 0.71 3.8
4 Shade 3.18 1.4
5 Shade 2.50 2.2
6 Shade 1.46 2.5
The code I am using is as follows:
shade_lm3 <- lm(Leaf_lifespan ~ Min_light_reqs, data = shade)
gap_lm3 <- lm(Leaf_lifespan ~ Min_light_reqs, data = gap)
plot(d1$Leaf_lifespan ~ d1$Min_light_reqs, log="xy", pch=21, col="black", bg="white",
xlim=c(0.5, 5), ylim = c(0.5, 10), cex=2, xaxt="n", yaxt="n", cex.lab=1.7)
points(shade$Leaf_lifespan ~ shade$Min_light_reqs, pch=21, col="black",
bg="black", cex=2)
abline(shade_lm3)
abline(gap_lm3)
axis(1, tick=TRUE, line=0, at=c(0.5, 1, 2, 5), labels=c(0.5, 1, 2, 5))
axis(2, tick=TRUE, line=0, at=c(0.5, 1, 2, 5, 10), labels=c(0.5, 1, 2, 5, 10))
If I remove the log="xy" then the model lines show up and the plots look perfect. How do I keep the log scale axes and the ablines?