get_default_params | R Documentation |
What are the default parameters for a plot layer?
get_default_params(p, geom, params = NULL, i = NULL)
p |
A ggplot object |
geom |
A character string found in the suffix of a ggplot2 geom function,
e.g. |
params |
A character vector.
|
i |
A numerical index, e.g. |
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
.
Other functions for checking geom parameters:
uses_geom_params()
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.