Learn R Programming

ggformula (version 0.4.0)

gf_abline: Reference lines -- horizontal, vertical, and diagonal.

Description

These fuctions create layers that display lines described i various ways. Unlike most of the plotting functions in ggformula, these functions do not take a formala as input for describing positional attributes of the plot.

Usage

gf_abline(object = NULL, gformula = NULL, data = NULL, geom = type,
  verbose = FALSE, add = inherits(object, c("gg", "ggplot")), ...,
  position = NULL, show.help = NULL)

gf_hline(object = NULL, gformula = NULL, data = NULL, geom = type, verbose = FALSE, add = inherits(object, c("gg", "ggplot")), ..., position = NULL, show.help = NULL)

gf_vline(object = NULL, gformula = NULL, data = NULL, geom = type, verbose = FALSE, add = inherits(object, c("gg", "ggplot")), ..., position = NULL, show.help = NULL)

gf_coefline(object = NULL, coef = NULL, model = NULL, ...)

Arguments

object

When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples.

gformula

Must be NULL.

data

A data frame with the variables to be plotted.

geom

A way to specify ggplot geoms that are not aliased to gf functions.

verbose

If TRUE print the ggplot2 command in the console.

add

If TRUE then construct just the layer with no frame. The result can be added to an existing frame.

...

Additional arguments. Typically these are (a) ggplot2 aesthetics to be set with attribute = value, (b) ggplot2 aesthetics to be mapped with attribute = ~expression, or (c) attributes of the layer as a whole, which are set with attribute = value. Available attributes include slope, intercept

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

show.help

If TRUE, display some minimal help.

coef

A numeric vector of length at least 2, treated as intercept and slope. Additional components, if any, are ignored (with a warning).

model

An object with a method for coef() that returns a numeric vector, the first two elements of which are intercept and slope. This is equivalent to coef = coef(model).

See Also

geom_abline(), geom_vline(), geom_hline()

Examples

Run this code
# NOT RUN {
gf_point(mpg ~ hp, color = ~cyl, size = ~wt, data = mtcars) %>%
  gf_abline(color="red", slope = -0.10, intercept = 35)
gf_point(mpg ~ hp, color = ~cyl, size = ~wt, data = mtcars) %>%
  gf_abline(color = "red", slope = -0.10, intercept = 33:36) %>%
  gf_hline(color = "navy", yintercept = c(20, 25)) %>%
  gf_vline(color = "brown", xintercept = c(200, 300))
# }

Run the code above in your browser using DataLab