get_default_params: What are the default parameters for a plot layer?

View source: R/geom_params.R

get_default_paramsR Documentation

What are the default parameters for a plot layer?

Description

What are the default parameters for a plot layer?

Usage

get_default_params(p, geom, params = NULL, i = NULL)

Arguments

p

A ggplot object

geom

A character string found in the suffix of a ggplot2 geom function, e.g. "point".

params

A character vector. get_default_params() returns the default parameter value with a name matching each string in params. If params is NULL (the default), the default values for all parameters are returned.

i

A numerical index, e.g. 1.

Value

A named list of the same length as params, or, if params is NULL, a named list of default values for all parameters of geom.

See Also

Other functions for checking geom parameters: uses_geom_params()

Examples

require(ggplot2)

p <- ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
  geom_smooth(aes(color = class))

# Returns the parameters the ggplot would use by default for a layer
get_default_params(p, "smooth", "linetype")
get_default_params(p, "smooth", c("se", "level"))
get_default_params(p, "smooth")

# If a parameter does not exist, returns NULL
get_default_params(p, "smooth", "shape")

# The colo(u)r aesthetic can be matched with or without a u
get_default_params(p, "smooth", "color")
get_default_params(p, "smooth", "colour")

rstudio-education/ggcheck documentation built on May 12, 2023, 11:33 a.m.