Reputation: 35
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
Upvotes: 3
Views: 1939
Reputation: 10761
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.
Upvotes: 2