Skip to contents

Set collected guide layout on an 'aplot' object

Usage

set_guide_layout(
  x,
  legend_ncol = NULL,
  legend_byrow = FALSE,
  legend_title_position = NULL,
  legend_direction = NULL,
  legend_keywidth = NULL,
  legend_keyheight = NULL,
  legend_spacing_x = NULL,
  legend_spacing_y = NULL,
  guides_ncol = NULL,
  guides_byrow = FALSE,
  guides_direction = NULL
)

Arguments

x

an 'aplot' object

legend_ncol

number of columns used inside each individual legend. Must be a positive integer. If `NULL`, the internal column layout of each legend is left unchanged.

legend_byrow

logical; whether keys inside each individual legend should be filled row-wise when a multi-column legend is created. The default is `FALSE`.

legend_title_position

title position used inside each individual legend. Must be one of `"top"`, `"bottom"`, `"left"`, or `"right"`. If `NULL`, the current title position is left unchanged.

legend_direction

direction used inside each individual legend. Must be one of `"horizontal"` or `"vertical"`. If `NULL`, the current legend direction is left unchanged.

legend_keywidth, legend_keyheight

legend key size in millimeters for each individual legend. These values are converted to `grid::unit(..., "mm")` and passed to [ggplot2::guide_legend()]. If `NULL`, the corresponding key dimension is left unchanged.

legend_spacing_x, legend_spacing_y

spacing between legend items in millimeters inside each individual legend. These values are converted to `grid::unit(..., "mm")` and applied through [ggplot2::theme()] as `legend.spacing.x` and `legend.spacing.y`. If `NULL`, the corresponding spacing is left unchanged.

guides_ncol

number of columns used to arrange multiple collected legend boxes as a group. Must be a positive integer. If `NULL`, the group layout stays in a single strip determined by `guides_direction`.

guides_byrow

logical; whether collected legend boxes should be filled row-wise when a wrapped guide group is created. The default is `FALSE`.

guides_direction

overall direction used to arrange multiple collected legend boxes. Must be one of `"horizontal"` or `"vertical"`. If `NULL`, the default follows the guide placement side used by [set_guide_area()].

Value

an 'aplot' object

Details

Control collected guides at two semantic levels when an 'aplot' object is rendered. Use [set_guide_area()] to decide where guides should go, and use `set_guide_layout()` to decide how they should be arranged once placed.