You can add a line
par(new=TRUE)
Then use qqplot () again to overlay the first chart as follows:
set.seed(10) dat <- data.frame(A = rnorm(20), B = rnorm(20), C = rnorm(20)) # create a QQ-plot of B as a function of A qqplot(dat$A, dat$B, xlim = range(dat), ylim = range(dat), xlab = "Distribution A", ylab = "Other distributions") # set overplotting par(new=TRUE) # create a QQ-plot of B as a function of C qqplot(dat$A, dat$C, xlim = range(dat), ylim = range(dat), xlab = "Distribution A", ylab = "Other distributions", col = "red") # create a diagonal line abline(a = 0, b = 1) # create a legend legend("bottomright", legend = c("B", "C"), pch = 1, col = c("black", "red"))
source share