equalizeWidths: Equalize box widths

View source: R/boxGrobs_equalizeWidths.R

equalizeWidthsR Documentation

Equalize box widths

Description

Sets selected boxes to a shared width. This is useful when aligning flowchart levels so corresponding boxes have consistent visual width and center points.

Usage

equalizeWidths(x, subelement = NULL, width = NULL)

Arguments

x

A list of boxes (or nested lists of boxes). Can also be a single box.

subelement

Optional target(s) inside x. Can be a single path (e.g. c("groups", 1)) or a list of paths (e.g. list(c("groups", 1), c("groups2", 1))). If NULL, all top-level boxes in x are used.

width

Optional width to apply. If NULL, the maximum current width among selected boxes is used.

Value

The updated object with equalized widths.

See Also

Other flowchart components: align(), append(), boxGrob(), boxHeaderGrob(), boxPropGrob(), boxShapes, connectGrob(), coords(), distance(), flowchart(), insert(), move(), moveBox(), spread()

Examples

fc <- flowchart(
  groups = list("Group 1", "Group 2"),
  groups2 = list("Analysed", "Analysed")
)

fc |>
  equalizeWidths(subelement = list(c("groups", 1),
                                   c("groups2", 1),
                                   c("groups", 2),
                                   c("groups2", 2)))

# Global fixed width via explicit argument
fc |> equalizeWidths(subelement = "groups", width = grid::unit(30, "mm"))

Gmisc documentation built on June 2, 2026, 9:07 a.m.