df <- data.frame(y = rt(200, df = 5)) p <- ggplot(df, aes(sample = y)) p + stat_qq() p + geom_point(stat = "qq") # Use fitdistr from MASS to estimate distribution params params <- as.list(MASS::fitdistr(df$y, "t")$estimate) ggplot(df, aes(sample = y)) + stat_qq(distribution = qt, dparams = params["df"]) # Using to explore the distribution of a variable ggplot(mtcars) + stat_qq(aes(sample = mpg)) ggplot(mtcars) + stat_qq(aes(sample = mpg, colour = factor(cyl))) Run the code above in your browser using DataLab