Skip to contents

Plot fieldbook sketches for Splitplot-RCBD experimental designs generated by design_split_rcbd().

Usage

plot_split_rcbd_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 design_split_rcbd().

factor

Character scalar. Column used to color experimental units. If missing, "wp_sp" is used when available; otherwise, "ntreat" is used.

fill

Character vector. Column or columns used as labels inside each experimental unit. Default is "plots".

xlab

Character scalar. Optional x-axis title. If NULL, "Whole plots" is used.

ylab

Character scalar. Optional y-axis title. If NULL, "Subplots" is used when rows can be interpreted consistently as subplot positions within blocks; otherwise, "Rows" is used.

glab

Character scalar. Optional legend title.

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 dimensions of each block, font size and number of label columns. Underscores are displayed as spaces only in the sketch; the 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, facet titles and legends. Defaults to "plain".

Value

A ggplot object.

Details

The function does not recalculate or rearrange the experimental design. It uses the existing rows and cols coordinates from the fieldbook, so the physical arrangement and zigzag order generated by Tarpuy are preserved.

Every experimental unit is positioned with cols on the x axis and rows on the y axis. The block column is used only to identify the block panels; it never replaces the physical row coordinate.

Within each block, cols represents whole-plot positions. The visible y-axis tick labels are derived from the rank of the actual rows values inside each block, so the panels can display subplot positions while the geometry continues to use the original fieldbook coordinates. A black external border identifies each whole plot.

Automatic wrapping affects only the displayed labels. It does not change plots, ntreat, treatment factors, QR codes, rows, columns or any other fieldbook value.

Examples

if (FALSE) { # \dontrun{

plot_split_rcbd_design(
  data = fieldbook,
  factor = "wp_sp",
  fill = c("plots", "ntreat"),
  text_size = 9,
  font_family = "Open Sans",
  font_face = "plain"
)

} # }