View source: R/boxGrobs_labelConnector.R
| labelConnector | R Documentation |
Place text labels at the midpoint of connector grobs returned by ‘connectGrob()' (useful for multi-target connectors where 'label=' isn’t available). By default the function draws the labels; set 'draw = FALSE' to only return the 'textGrob' objects for programmatic use.
labelConnector(
con,
labels,
x_offset = unit(0, "mm"),
y_offset = unit(0, "mm"),
gp = gpar(cex = 0.9),
bg_gp = gpar(fill = "white", col = NA),
pad = unit(2, "mm")
)
con |
A list of connector grobs produced by 'connectGrob()' (typically a 'connect_boxes_list'). |
labels |
A character vector of labels (recycled if necessary). |
x_offset, y_offset |
'grid::unit' offsets added to the label position. |
gp |
A 'grid::gpar' object controlling text appearance. |
bg_gp |
A 'grid::gpar' object controlling label background appearance. |
pad |
A 'grid::unit' padding to add around text inside the background box. |
A 'Gmisc_connector_label' S3 object (invisible). Use 'print()' to draw the labels.
# Attach labels to a previously-created connector and draw them
a <- boxDiamondGrob("D")
b <- boxEllipseGrob("L")
c <- boxServerGrob("S")
boxes <- list(decision = a, outcomes = list(b, c)) |>
spreadHorizontal(
from = grid::unit(.1, "npc"),
to = grid::unit(.9, "npc"),
subelement = "outcomes"
) |>
spreadVertical()
connectGrob(boxes$decision, boxes$outcomes, type = "N") |>
labelConnector(c("Local", "Server"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.