x <- rchisq(100, 3)
qqdf <- qqPoints(x)
a <- attr(qqdf, "ab")[1]
b <- attr(qqdf, "ab")[2]
l <- min(qqdf$theo) * b + a
u <- max(qqdf$theo) * b + a
library(ggplot2)
ggplot(qqdf, aes(x=theo, y=x)) +
geom_ribbon(aes(ymin=lwr, ymax=upr), alpha=.15) +
geom_segment(aes(x=min(qqdf$theo), xend=max(qqdf$theo), y = l, yend=u)) +
geom_point(shape=1) +
theme_classic() +
labs(x="Theoretical Quantiles",
y="Observed Quantiles")
Run the code above in your browser using DataLab