plotRelativeDataFrame: Make a plot of the relative difference between two data...

View source: R/plots.R

plotRelativeDataFrameR Documentation

Make a plot of the relative difference between two data frames

Description

Used internally by plotSpectraRelative() and similar functions. The two data frames are matched up on their shared variables and the relative difference of their y-values is plotted against the x-variable.

Usage

plotRelativeDataFrame(
  frame1,
  frame2,
  params,
  xlab = waiver(),
  xtrans = "identity",
  xlim = c(NA, NA),
  ylim = c(NA, NA),
  highlight = NULL,
  legend_var = "Legend",
  interpolate = FALSE
)

Arguments

frame1, frame2

Data frames sharing the same first three variables (x, y and grouping variable). The names of frame1 are imposed on frame2.

params

A MizerParams object, used for the line colours.

xlab

Label for the x-axis.

xtrans

Transformation for the x-axis, e.g. "log10" or "identity".

xlim, ylim

Numeric vectors of length two giving the axis limits. Use NA to refer to the existing minimum or maximum.

highlight

Name or vector of names of the species to be highlighted.

legend_var

Name of the variable used in the legend and to determine the line colour.

interpolate

Whether the two series may sit on different x-grids and should be interpolated onto a common one, see interpolate_relative_frames(). TRUE for a size axis, where the two models can convert weight to length differently; FALSE for a time axis, where they share the saved times or share nothing.

Details

Both data frames must arrive ready to plot, on the axis they will be drawn against and with any total line already among their rows. See plotComparisonDataFrame() for why the preparation belongs to whatever produced each operand rather than here.

Value

A mizer_plot (ggplot2) object showing the relative difference.


mizer documentation built on Aug. 24, 2026, 9:08 a.m.