add_structure: Add a Structure

Description Usage Arguments Details Value Examples

View source: R/structures.R

Description

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

Usage

1
add_structure(grob_object, structure, value)

Arguments

grob_object

The R6 object initialized by one of:

  • grob_matrix

  • grob_image

  • grob_text

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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()
  

grobblR documentation built on Sept. 15, 2021, 1:07 a.m.