Skip to contents

Plot fieldbook sketches for augmented experimental designs generated by design_augmented().

Usage

plot_augmented_design(
  data,
  factor = NA,
  fill = "plots",
  xlab = NULL,
  ylab = NULL,
  glab = NULL,
  text_size = NULL,
  wrap_width = NULL,
  font_family = "Open Sans",
  font_face = "plain"
)

Arguments

data

Fieldbook data frame from an augmented design.

factor

Character scalar. Column used to color experimental units. If missing, "type" is used.

fill

Character vector. Column or columns used as labels inside each experimental unit. Default is "plots". When ntreat is selected, it is displayed as T1, T2, etc.

xlab

Character scalar. Optional x axis title. If NULL, "Columns" is used.

ylab

Character scalar. Optional y axis title. If NULL, the title is "Blocks" when every physical row corresponds to exactly one statistical block; otherwise "Rows" is used.

glab

Character scalar. Optional legend title. If NULL, the selected color factor is used.

text_size

Optional positive numeric scalar indicating the plot-label font size in typographic points (pt). If NULL or NA, a suitable default is selected according to the number of label columns. The value is converted internally to the unit expected by ggplot2::geom_text().

wrap_width

Optional positive integer indicating the approximate maximum number of characters per line. If NULL or NA, the function calculates it automatically from the field dimensions, font size and number of label columns. Underscores are displayed as spaces only in the sketch; the original fieldbook values are not modified.

font_family

Character scalar. Font family used in the sketch. Defaults to "Open Sans". If the font cannot be verified through the optional systemfonts package, "sans" is used as a fallback.

font_face

Character scalar. Font face used in labels, axes and legends. Defaults to "plain".

Value

A ggplot object.

Details

The function always uses the physical rows and cols coordinates stored in the fieldbook. Therefore, custom dimensions and zigzag layouts are preserved. The block column never replaces rows as a plotting coordinate. When each row represents exactly one block, only the visible y-axis title changes from "Rows" to "Blocks". The statistical block remains available as a color factor and, when a block occupies a complete rectangular region, its external border is highlighted.

Empty experimental units are represented by the level "empty". When factor = "type", checks, test entries and empty plots receive stable colors. Other factor columns use the regular TARPUY color palette.

Automatic wrapping and formatting affect only the displayed text. They do not modify entry, plots, ntreat, QR codes or any other fieldbook value.

Examples

if (FALSE) { # \dontrun{

plot_augmented_design(
  data = fieldbook,
  factor = "type",
  fill = c("plots", "entry"),
  text_size = 9,
  font_family = "Open Sans",
  font_face = "plain"
)

} # }