powered by
Extract plot components from a ggplot or gtable. get_plot_component() extracts grobs or a list of grobs. plot_component_names() provides the names of the components in the plot. plot_components() returns all components as a list.
get_plot_component()
plot_component_names()
plot_components()
get_plot_component(plot, pattern, return_all = FALSE)plot_component_names(plot)plot_components(plot)
plot_component_names(plot)
plot_components(plot)
A grob or list of grobs (get_plot_component(), plot_components()) or a character vector (plot_component_names())
A ggplot or gtable to extract from.
The name of the component.
If there is more than one component, should all be returned as a list? Default is FALSE.
FALSE
library(ggplot2) p <- ggplot(mpg, aes(displ, cty)) + geom_point() ggdraw(get_plot_component(p, "ylab-l"))
Run the code above in your browser using DataLab