简体   繁体   中英

How can I fit one linear regression line in one graph for my 3 plots?

I have a problem in R and I need a little help.I want to fit linear progression line in a graph with 3 different plots that I have created and I cannot find the right code. For three separate linear progression lines, each one for each of my 3 plots, I have no problem...but for a total linear progression line for all my 3 plots I cannot find something useful. Any kind of help would be appreciated...here is my code:

plot(Age ,Depth, type="l", xlim= rev(c(min_x, max_x)), ylim= rev(c(min_y, max_y)), 
           col= "red", xaxt='n',  yaxt='n', xaxs="i", yaxs="i", xlab=NA, ylab=NA)
lines(Age1, Depth1, col="dark green")
lines(Age2, Depth2, col="blue")
axis(side= 3)
axis(side= 4, las=2)
mtext(side=3, line=2.3 , "Age (Ma)")
par(mar = c(5, 4, 4, 8) + 0.2)
mtext(side=4, line=3 , "Depth (mcd)")
AgeAll   = c(Age, Age1, Age2)
DepthAll = c(Depth, Depth1, Depth2)
abline(lm(DepthAll ~ AgeAll))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM