问题
How to add lines to the chart? I did following
dat <- data.frame(xvar = 1:20 - rnorm(20,sd=10),
yvar = 1:20 - rnorm(20,sd=10),
zvar = 1:20 - rnorm(20,sd=10))
plot(dat[,1:3])

But I need horizontal and vertical lines at the value zero of all variables, like this

回答1:
Something like this might work:
##define a function to use in pairs
plotfun <- function(x,y,...){
points(x,y,...) #plot them
abline(h = 0) #horizontal line
abline(v = 0) #vertical line
}
pairs(dat, upper.panel = plotfun)
Note that this question is very similar to this one.
来源:https://stackoverflow.com/questions/37008771/add-lines-to-scatterplot-in-r