1

I am very much an R novice so I am guessing this question is rather stupid/simple...

I have two vectors that represent two samples. I would like to plot each of them (different colors) against the uniform CDF (something like a Q-Q plot).

To be precise, I would like something very similar to plot #7 here (could not find what was used to draw that plot...). Figure 7 is displayed below:

enter image description here

only with multiple samples and some flexibility with changing the axis labels, colors and such.

Could you please point at a good direction?

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
N.M
  • 685
  • 1
  • 9
  • 22
  • 1
    A good starting point could be reading [`?qqplot`](http://stat.ethz.ch/R-manual/R-patched/library/stats/html/qqnorm.html). – Jilber Urbina Dec 08 '13 at 14:39
  • I once [tried to do something similar with `ggplot`](http://stackoverflow.com/questions/19599745/qqline-in-ggplot2-with-facets/19600903#19600903). – Henrik Dec 08 '13 at 17:33
  • Thank you both. I chose to use ggplot + stat_qq. I now struggle with tinier problems :-\ http://stackoverflow.com/questions/20499216/changing-line-width-in-stat-qq-with-ggplot-in-r – N.M Dec 10 '13 at 16:01

2 Answers2

2

For example:

set.seed(10)
N <- 1000
B = rt(N,df=10)
C = rchisq(N,df=10)
op <- layout(matrix(c(1,2),ncol=2,nrow=1))
qqnorm(B,col='green',ylab='student')
qqline(B, col = 2)
qqnorm(C,col='blue',ylab=expression( chi^2 ))
qqline(C, col = 2)
agstudy
  • 119,832
  • 17
  • 199
  • 261
0

The basics for drawing a QQ-plot are:

qqnorm(variable, main = "QQ Plot", xlab = "Theoretical Quantiles", ylab = "Sample Quantiles")
qqline(variable, col = "red")
Jaap
  • 81,064
  • 34
  • 182
  • 193