Create a
grob
with text inside. To extract the units describing
grob boundary location can be accessed with
grobX
and
grobY
. The units describing width and height can be accessed with
grobWidth
and
grobHeight
.
Usage
textbox(
text,
x = unit(0.5, "npc"),
y = unit(0.5, "npc"),
just = c("center", "left", "right"),
txt_gp = getOption("txt_gp", default = gpar(color = "black", cex = 1)),
box_fn = roundrectGrob,
box_gp = getOption("box_gp", default = gpar(fill = "white")),
name = "textbox"
grid.textbox(...)
Arguments
A character text to be passed to textGrob.
A number or unit object specifying x-location.
A number or unit object specifying y-location.
The justification of the text, '"left"', '"right' and '"center"'.
See textGrob for more details.
txt_gp
An object of class gpar style to be applied to the
text. This will also be read from global options of "txt_gp"
. For
example, if one wants to set a font size for all the text inside box,
options(txt_gp = gpar(cex = 0.8))
will do the trick.
box_fn
Function to create box for the text. Parameters of 'x=0.5',
'y=0.5' and 'box_gp' will be passed to this function and return a grob
object. This will also be read from global options of "box_gp"
.
box_gp
An object of class gpar style to be applied to the
A character identifier.
Parameters passed to textbox
fg <- textbox(text = "This is a test")
grid::grid.draw(fg)
grid.textbox(text = "This is a test")
grid.textbox(text = "This is a test")