Learn R Programming

ggpubr (version 0.1.1)

ggqqplot: QQ Plots

Description

Quantile-Quantile plot.

Usage

ggqqplot(data, x, color = "black", palette = NULL, size = NULL, add = c("qqline", "none"), add.params = list(linetype = "solid"), conf.int = TRUE, conf.int.level = 0.95, ggtheme = theme_classic2(), ...)

Arguments

data
a data frame
x
variable to be drawn.
color
point color.
palette
the color palette to be used for coloring or filling by groups. Allowed values include "grey" for grey color palettes; brewer palettes e.g. "RdBu", "Blues", ...; or custom color palette e.g. c("blue", "red"); and scientific journal palettes from ggsci R package, e.g.: "npg", "aaas", "lancet", "jco", "ucscgb", "uchicago", "simpsons" and "rickandmorty".
size
point size.
add
character vector. Allowed values are one of "none" and "qqline" (for adding qqline).
add.params
parameters (color, size, linetype) for the argument 'add'; e.g.: add.params = list(color = "red").
conf.int
logical value. If TRUE, confidence interval is added.
conf.int.level
the confidence level. Default value is 0.95.
ggtheme
function, ggplot2 theme name. Default value is theme_pubr(). Allowed values include ggplot2 official themes: theme_gray(), theme_bw(), theme_minimal(), theme_classic(), theme_void(), ....
...
other arguments to be passed to stat_qq and ggpar.

Details

The plot can be easily customized using the function ggpar(). Read ?ggpar for changing:
  • main title and axis labels: main, xlab, ylab
  • axis limits: xlim, ylim (e.g.: ylim = c(0, 30))
  • axis scales: xscale, yscale (e.g.: yscale = "log2")
  • color palettes: palette = "Dark2" or palette = c("gray", "blue", "red")
  • legend title, labels and position: legend = "right"
  • plot orientation : orientation = c("vertical", "horizontal", "reverse")

See Also

ggpar

Examples

Run this code
# Create some data format
set.seed(1234)
wdata = data.frame(
   sex = factor(rep(c("F", "M"), each=200)),
   weight = c(rnorm(200, 55), rnorm(200, 58)))

head(wdata, 4)

# Basic QQ plot
ggqqplot(wdata, x = "weight")

# Change colors and shape by groups ("sex")
# Use custom palette
ggqqplot(wdata, x = "weight",
   color = "sex", palette = c("#00AFBB", "#E7B800"))

Run the code above in your browser using DataLab