Generate layout matrix for gridExtra::grid.arrange

prepare_layout_matrix(
  grobs_list = NULL,
  last_is_legend = TRUE,
  n_col = NULL,
  scale_legend = 1
)

Arguments

grobs_list

A list of graphical objects (grobs)

last_is_legend

Whether last graphical object is legend

n_col

Number of columns for plotting

scale_legend

Scaled width of legend

Examples

prepare_layout_matrix( grobs_list = list(A=1,B=2,C=3) )
#> $ncol
#> [1] 3
#> 
#> $widths
#> [1] 2 2 1
#> 
#> $heights
#> [1] 2
#> 
#> $layout_matrix
#>      [,1] [,2] [,3]
#> [1,]    1    2    3
#> 

prepare_layout_matrix( grobs_list = 1:3,
                       last_is_legend = FALSE )
#> $ncol
#> [1] 2
#> 
#> $widths
#> [1] 2 2
#> 
#> $heights
#> [1] 2 2
#> 
#> $layout_matrix
#>      [,1] [,2]
#> [1,]    1    2
#> [2,]    3   NA
#>