nested_loop_base_plot: Basic facetted nested loop plots

View source: R/nested_loop.R

nested_loop_base_plotR Documentation

Basic facetted nested loop plots

Description

Builds basic nested loop plots from output of nested_loop_base_data. This function is more flexible than the functionality offered by nested_loop_plot regarding drawing the basis of a facetted nested loop plot. Usually only interesting to advanced users. Most parameter definitions are the same as in nested_loop_plot.

Usage

nested_loop_base_plot(
  plot_data,
  grid_scales = "fixed",
  y_name = waiver(),
  x_name = waiver(),
  legend_name = "Method",
  legend_breaks = waiver(),
  legend_labels = NULL,
  labeller = label_both_custom,
  draw = list(add_points = list(alpha = 1), add_lines = list(size = 0.5, alpha = 1)),
  connect_spus = FALSE,
  colors = NULL,
  shapes = 19,
  linetypes = 1,
  sizes = 1,
  x_labels = waiver(),
  ylim = NULL,
  y_breaks = waiver(),
  y_labels = waiver(),
  na_rm = TRUE,
  base_size = 12
)

Arguments

plot_data

Output list from nested_loop_base_data.

grid_scales

Analogous to scales argument of facet_grid.

y_name

Character which is used as y-axis label.

x_name

Character which is used as x-axis label.

legend_name

String which is used as legend name.

legend_breaks

A character vector of breaks for the scales. Can be used to e.g. exclude certain methods from the legend. If NULL, then no breaks are displayed in the legend. Otherwise, must be the same length as legend_labels, if one of them is changed from the default.

legend_labels

NULL or character vector which is used as keys in legend. Overrides variable columns names in resdf. Must be the same length as legend_breaks, if one of them is changed from the default.

labeller

Labeller function to format strip labels of the facet grid. By default uses a custom version of ggplot2::label_both, but can be customized according to labeller.

draw

Named list of lists. Each entry specifies as its name a wrapper function (one of add_points, add_lines, add_steps) and has as entry a list of named arguments which are passed to that wrapper function via do.call. The arguments passed here correspond to the point_shapes/size/alpha and line_linetypes/size/alpha arguments in nested_loop_plot.

connect_spus

Logical - if TRUE, individual spus are connected by lines, this is necessary to reproduce original nested loop plots as suggested in the manuscript by Ruecker and Schwarzer (2014). The default FALSE means not to connect indidivual spus which often makes it easier to spot patterns in the results.

colors

NULL, vector of color specification of length equal to the number of measurement columns (M) in resdf, or a function. If NULL, the viridis color scale is used (see viridis). If a function, then it is expected that the function takes a single argument *n* and returns a vector of color specifications of length *n* (e.g. use the brewer_pal function).

shapes

Single numeric or numeric vector, specifies custom shape scale for points added to the plot. Cycled as necessary. Corresponds to the point_shapes argument in nested_loop_plot.

linetypes

Single numeric or numeric vector, specifies custom linetypes scale for lines added to the plot. Cycled as necessary. Corresponds to the line_linetypes argument in nested_loop_plot.

sizes

Single numeric or numeric vector, specifies custom sizes for lines and points added to the plot. Cycled as necessary. Note that this scale affects both points and lines due to the implementation in the underlying ggplot2 package. Corresponds to the sizes argument in nested_loop_plot.

x_labels

If set to NULL, no labels are drawn on x-axis.

ylim

Vector of length 2 with limits of y-axis for the measurement data. Steps drawn (due to steps_draw TRUE) are not affected and will adapt to this setting automatically.

y_breaks

Vector with user specified breaks of the y-axis. Default is to use the breaks as suggested by ggplot2.

y_labels

Vector with user specified labels of the y-axis. Default is to use the labels as suggested by ggplot2.

na_rm

Logical. Should missing values be removed before plotting? This means that lines will be connected, even if a missing value is between two values.

base_size

Numeric. base_size parameter of theme_bw.

Value

A ggplot2 object.


matherealize/looplot documentation built on Jan. 14, 2024, 2:07 a.m.