Skip to contents

Provides six plot types for visualising BLUP accuracy computed by accuracy(): a lollipop summary, violin distribution, heatmap, and three two-model comparison plots (dumbbell, scatter, diff).

Usage

plot_accuracy(
  res,
  res2 = NULL,
  type = c("lollipop", "violin", "heatmap", "dumbbell", "scatter", "diff"),
  metric = c("accuracy", "gen.H2"),
  label1 = "Model 1",
  label2 = "Model 2",
  theme = ggplot2::theme_bw(),
  return_data = FALSE,
  ...
)

Arguments

res

Data frame returned by accuracy(). May be group-level or by-variety (by_variety = TRUE) depending on type.

res2

Optional second data frame from accuracy() for comparison plots ("dumbbell", "scatter", "diff").

type

Plot type – one of "lollipop", "violin", "heatmap", "dumbbell", "scatter", "diff".

metric

Character vector: "accuracy", "gen.H2", or both (default). When both are selected the plot is faceted into two panels.

label1

Legend label for res (comparison plots only).

label2

Legend label for res2 (comparison plots only).

theme

A ggplot2 theme object applied to all plots.

return_data

Logical. If TRUE, returns a list with elements $plot and $data instead of just the plot.

...

Currently unused.

Value

A ggplot object, or a named list when return_data = TRUE.

Examples

if (FALSE) { # \dontrun{
acc  <- accuracy(model_fa,   metric = c("accuracy","gen.H2"))
acc2 <- accuracy(model_diag, metric = c("accuracy","gen.H2"))

plot_accuracy(acc,       type = "lollipop")
plot_accuracy(acc_bv,    type = "violin")
plot_accuracy(acc_bv,    type = "heatmap")
plot_accuracy(acc, acc2, type = "dumbbell", label1 = "FA", label2 = "Diag")
plot_accuracy(acc_bv, acc2_bv, type = "scatter")
plot_accuracy(acc, acc2, type = "diff", label1 = "FA", label2 = "Diag")
} # }