qplot {ggplot2}R Documentation

Quick plot.

Description

Quick plot is a convenient wrapper function for creating simple ggplot plot objects.

Usage

qplot(x, y = NULL, z=NULL, ..., data, facets = . ~ ., margins=FALSE, geom = "auto", stat=list(NULL), position=list(NULL), xlim = c(NA, NA), ylim = c(NA, NA), log = "", main = NULL, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), asp = NA)

Arguments

x x values
y y values
z z values
... other arguments passed on to the geom functions
data data frame to use (optional)
facets faceting formula to use
margins whether or not margins will be displayed
geom geom to use (can be a vector of multiple names)
stat statistic to use (can be a vector of multiple names)
position position adjustment to use (can be a vector of multiple names)
xlim limits for x axis (aesthetics to range of data)
ylim limits for y axis (aesthetics to range of data)
log which variables to log transform ("x", "y", or "xy")
main character vector or expression for plot title
xlab character vector or expression for x axis label
ylab character vector or expression for y axis label
asp the y/x aspect ratio

Details

You can use it like you'd use the plot function.

Author(s)

Hadley Wickham <h.wickham@gmail.com>

Examples

# Use data from data.frame
qplot(mpg, wt, data=mtcars)
qplot(mpg, wt, data=mtcars, colour=cyl)
qplot(mpg, wt, data=mtcars, size=cyl)
qplot(mpg, wt, data=mtcars, facets=vs ~ am)

# Use data from local environment
attach(mtcars)
qplot(hp, wt)
qplot(hp, wt, colour=cyl)
qplot(hp, wt, size=cyl)
qplot(hp, wt, facets=vs ~ am)

qplot(1:10, rnorm(10), colour = runif(10))
qplot(1:10, letters[1:10])
mod <- lm(mpg ~ wt, data=mtcars)
qplot(resid(mod), fitted(mod))
qplot(resid(mod), fitted(mod), facets = . ~ vs)

f <- function() {
a <- 1:10
b <- a ^ 2
qplot(a, b)
} 
f()

# qplot will attempt to guess what geom you want depending on the input
# both x and y supplied = scatterplot
qplot(mpg, wt, data = mtcars)
# just x supplied = histogram
qplot(mpg, data = mtcars)
# just y supplied = scatterplot, with x = seq_along(y)
qplot(y = mpg, data = mtcars)

# Use different geoms
qplot(mpg, wt, geom="path")
qplot(factor(cyl), wt, geom=c("boxplot", "jitter"))

[Package ggplot2 version 0.8.2 Index]