Skip to contents

Plot standard fieldbook sketches for regular experimental designs generated in Tarpuy, including completely randomized designs (CRD/DCA) and randomized complete block designs (RCBD/DBCA).

Usage

plot_standard_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

A fieldbook data frame. It must contain at least rows and cols.

factor

Character scalar. Name of the column used to color the experimental units. If missing, "block" is used when available; otherwise, the third column of data is used.

fill

Character vector. Names of one or more columns used as labels inside each experimental unit. When ntreat is used, it is displayed as T1, T2, etc.

xlab

Character scalar. Title for the x axis. If NULL, "Columns" is used.

ylab

Character scalar. Title for the y axis. If NULL, "Blocks" is shown for RCBD/DBCA only when each physical row corresponds to exactly one block; otherwise "Rows" is used. The plotting coordinate always remains the physical rows column.

glab

Character scalar. Legend title. If NULL, 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 shown as spaces only in the plotted label; the original fieldbook values are not modified.

font_family

Character scalar. Font family used by 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 does not calculate or rearrange an experimental design. It uses the existing rows and cols coordinates from the fieldbook, so the physical layout and the zigzag order generated by Tarpuy are preserved.

All standard designs are plotted with cols on the x axis and rows on the y axis. A DBCA/RCBD is therefore displayed according to its actual physical coordinates rather than replacing the row coordinate with the block number. When rows and blocks have a strict one-to-one relationship, only the visible y-axis title changes to "Blocks". The block can still be selected as the color factor.

Automatic wrapping affects only the sketch. It does not change entry, ntreat, QR codes, factor levels or any other fieldbook value.

Examples

if (FALSE) { # \dontrun{

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

} # }