Extract plot components from a ggplot or gtable. get_plot_component()
extracts specific grobs or a list of grobs. Note that it omits zeroGrobs and
returns NULL if there is no non-zero grob to return. plot_component_names()
provides the names of the components in the plot. plot_components() returns all
components as a list.
A grob or list of grobs (get_plot_component(), plot_components())
or a character vector (plot_component_names())
Arguments
plot
A ggplot or gtable to extract from.
pattern
The name of the component.
return_all
If there is more than one component, should all be returned
as a list? Default is NA, which returns the first component with a warning.
TRUE returns all components. FALSE returns the first without warning.