box: Create a box with text

boxGrobR Documentation

Create a box with text

Description

Creates a grob box with text inside it.

Usage

boxGrob(
  label,
  y = unit(0.5, "npc"),
  x = unit(0.5, "npc"),
  width,
  height,
  just = "center",
  bjust = "center",
  txt_gp = getOption("boxGrobTxt", default = gpar(color = "black", cex = 1)),
  box_gp = getOption("boxGrob", default = gpar(fill = "white")),
  box_fn = roundrectGrob,
  name = NULL
)

## S3 method for class 'box'
print(x, ...)

## S3 method for class 'box'
plot(x, ...)

## S3 method for class 'box'
widthDetails(x)

## S3 method for class 'box'
heightDetails(x)

Arguments

label

The label to print - should be a number, text or expression.

y

The y position to put the box at. Can be either in npc (i.e. 0-1) or a unit.

x

The x position to put the box at. Can be either in npc (i.e. 0-1) or a unit.

width

The box automatically adapts the size but you can force by specifying the width

height

The box automatically adapts the size but you can force by specifying the height

just

The justification for the text: left, center or right.

bjust

The justification for the box: left, center, right, top or bottom. See the just option for the viewport

txt_gp

The gpar style to apply to the text. Set boxGrobTxt option if you want to customize all the boxes at once.

box_gp

The gpar style to apply to the box function of 'box_fn' below.

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.

name

a character identifier for the grob. Used to find the grob on the display list and/or as a child of another grob.

...

Passed to grid.draw

Value

A grob

The plot/print

To output the grob objects to the plot either call plot on the object or print it. Note that R automatically prints any object that is outputted to the console. The function calls in turn the grid.draw function on the object.

S3 from the grid package

Width and height functions address the coords attribute for the corresponding information. The widthDetails and heightDetails that provide information on an object.

See Also

Other flowchart components: align, boxPropGrob(), connectGrob(), coords(), distance(), moveBox(), spread

Examples

library(grid)
grid.newpage()
boxGrob("My box")

gforge/Gmisc documentation built on Aug. 30, 2023, 7:38 a.m.