View source: R/gtable-layouts.R
gtable_matrix | R Documentation |
This function takes a matrix of grobs and create a gtable matching with the grobs in the same position as they were in the matrix, with the given heights and widths.
gtable_matrix(
name,
grobs,
widths = NULL,
heights = NULL,
z = NULL,
respect = FALSE,
clip = "on",
vp = NULL
)
name |
a string giving the name of the table. This is used to name the layout viewport |
grobs |
a single grob or a list of grobs |
widths |
a unit vector giving the width of each column |
heights |
a unit vector giving the height of each row |
z |
a numeric matrix of the same dimensions as |
respect |
a logical vector of length 1: should the aspect ratio of
height and width specified in null units be respected. See
|
clip |
should drawing be clipped to the specified cells
( |
vp |
a grid viewport object (or NULL). |
A gtable of the same dimensions as the grobs matrix.
Other gtable construction:
gtable()
,
gtable_col()
,
gtable_row()
,
gtable_spacer
library(grid)
a <- rectGrob(gp = gpar(fill = "red"))
b <- circleGrob()
c <- linesGrob()
row <- matrix(list(a, b, c), nrow = 1)
col <- matrix(list(a, b, c), ncol = 1)
mat <- matrix(list(a, b, c, nullGrob()), nrow = 2)
gtable_matrix("demo", row, unit(c(1, 1, 1), "null"), unit(1, "null"))
gtable_matrix("demo", col, unit(1, "null"), unit(c(1, 1, 1), "null"))
gtable_matrix("demo", mat, unit(c(1, 1), "null"), unit(c(1, 1), "null"))
# Can specify z ordering
z <- matrix(c(3, 1, 2, 4), nrow = 2)
gtable_matrix("demo", mat, unit(c(1, 1), "null"), unit(c(1, 1), "null"), z = z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.