add_structure {grobblR}R Documentation

Add a Structure

Description

Add a structure to a grob matrix / image / text object.

Usage

add_structure(grob_object, structure, value)

Arguments

grob_object

The R6 object initialized by one of:

structure

The structure the user wishes to add.

value

If grob_object is outputted by grob_matrix, then a single value, or a vector of values corresponding to each column of the initial object passed through grob_matrix, the user wants to apply to the grob matrix object.

Otherwise, a single value to apply to the structure.

Details

Accepted structures:

Matrix / Text
  • column_widths_p

  • n_lines

  • padding_p

Image
  • aspect_ratio_multiplier

  • maintain_aspect_ratio

To see descriptions of the structures above, see the documentation of ga_list.

Value

The initial R6 object of the grob object class with its structure properties altered.

Examples


df = data.frame(x = c(5, 14, 6, 10), y = c(3, 30, 17, 7))
df %>%
  grob_matrix() %>% 
  add_structure(structure = 'column_widths_p', value = c(1, 4)) %>%
  view_grob()
  
gg = ggplot2::ggplot(data = df, mapping = ggplot2::aes(x = x, y = y)) +
  ggplot2::geom_line(color = 'red')
  
gg %>%
  grob_image() %>% 
  view_grob()
  

[Package grobblR version 0.2.1 Index]