get_grob_component: get_grob_component

View source: R/get_grob_component.R

get_grob_componentR Documentation

get_grob_component

Description

Function retrieves a grob component from a ggplot2 plot object.

Usage

get_grob_component(a_plot = NULL, component_name = NULL)

Arguments

a_plot

A required ggplot2 plot object

component_name

A required string that sets the components name

Value

A list of grob objects

Examples

library(ggplot2)
library(ggplotify)
library(grid)
library(RplotterPkg)

mtcars_plot <- ggplot2::ggplot(
  data = datasets::mtcars,
) +
ggplot2::geom_point(aes(x = mpg, y = wt, color = cyl), size = 3)

legend_right <- RplotterPkg::get_grob_component(
  a_plot = mtcars_plot,
  component_name = "guide-box-right"
)


deandevl/RplotterPkg documentation built on March 1, 2025, 11:17 a.m.