Skip to contents

Generates publication-ready figures (bars or points with SE/CI error bars and compact letter displays) styled for high-impact journals (Nature, Crop Science, JXB). Supports single-factor, 2-way factorial (grouped bars), and 3-way factorial (grouped and faceted) designs.

Usage

plot_publication(
  object,
  type = c("bar", "point"),
  error_bar = c("se", "ci"),
  palette = c("okabe_ito", "forest", "academic_dark", "grayscale"),
  x_var = NULL,
  group_var = NULL,
  facet_var = NULL,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  posthoc = NULL,
  trt = NULL,
  by = NULL,
  posthoc_method = c("tukey", "lsd", "duncan", "scheffe", "bonferroni", "dunn"),
  posthoc_adjust = NULL,
  posthoc_alpha = 0.05
)

Arguments

object

An object of class `"agri_fitted_model"`, `"agri_posthoc"`, or `"agri_ranking"`.

type

Plot type: `"bar"` (column plot with error bars) or `"point"` (point + error bar).

error_bar

Statistic for error bars: `"se"` (Standard Error) or `"ci"` (95% Confidence Interval).

palette

Academic color palette: `"okabe_ito"`, `"forest"`, `"academic_dark"`, or `"grayscale"`.

x_var

Optional character name of factor to place on X-axis.

group_var

Optional character name of factor for color fill / grouping.

facet_var

Optional character name of factor for panel faceting.

title

Optional plot title. If `NULL`, auto-generated.

xlab

Optional X-axis title.

ylab

Optional Y-axis title.

posthoc

Optional `"agri_posthoc"` object. If supplied, its estimates and grouping letters are used without recomputation.

trt

Optional treatment factor(s) passed to agri_posthoc when `object` is a fitted model.

by

Optional conditioning factor(s) passed to agri_posthoc when `object` is a fitted model.

posthoc_method

Multiple-comparison method used for automatic letters.

posthoc_adjust

Optional p-value adjustment passed to agri_posthoc.

posthoc_alpha

Significance level used for automatic grouping letters.

Value

A `ggplot2` plot object that can be further customized or saved with ggplot2::ggsave().

Examples

data(wheat_splitplot, package = "agriDesignR")
fit <- fit_experiment(
  data = wheat_splitplot,
  response = "grain_yield",
  main_plot = "temperature",
  sub_plot = "genotype",
  block = "block"
)
# 2-way factorial grouped plot:
p2 <- plot_publication(fit, type = "bar", x_var = "genotype", group_var = "temperature")
#> Note: adjust = "tukey" was changed to "sidak"
#> because "tukey" is only appropriate for one set of pairwise comparisons
# print(p2)