Skip to contents

Builds faceted scatterplots from validate_flow_residuals() data. The default comparison is adjusted versus benchmark, with colour showing the signed difference between the second and first named series. For a single comparison, axis labels name the selected X and Y series directly; for multiple comparisons, facet headers include the compared series.

Usage

validate_flow_plot_scatter(
  residuals,
  comparisons = "adjusted_vs_benchmark",
  methods = NULL,
  method_col = "method",
  method_labels = NULL,
  facet_ncol = NULL,
  difference_limits = NULL,
  difference_quantile = 0.95,
  white_band = 0.22,
  point_alpha = 0.45,
  point_size = 1.1,
  point_outline = TRUE,
  point_outline_colour = "#6B7280",
  point_stroke = 0.12,
  sort = c("none", "ascending", "descending"),
  sort_metric = c("median_absolute_residual", "mean_absolute_residual", "mean_residual")
)

Arguments

residuals

A data frame, one validate_flow_residuals() result, or a named list of validate_flow_residuals() results.

comparisons

Comparisons to plot. Defaults to "adjusted_vs_benchmark". Use a character vector to compare multiple flow-pair definitions. When "raw_vs_benchmark" is included, it is shown once as the unadjusted raw MPD baseline.

methods

Optional character vector of method identifiers or display labels to include. Default NULL includes all methods.

method_col

Column containing the method identifier. Default "method".

method_labels

Optional named character vector used to relabel methods.

facet_ncol

Optional number of facet columns. Use this to keep multi-method scatterplots compact and avoid very wide panels. Default NULL lets ggplot2::facet_wrap() choose the layout.

difference_limits

Optional numeric vector of length 2 giving the colour-scale limits for the signed difference. Values outside the limits are squished to the end colours.

difference_quantile

Quantile of absolute signed differences used for robust symmetric colour limits when difference_limits = NULL. Set to 1 to use the full observed range. Default 0.95.

white_band

Width of the neutral white band around zero as a proportion of the colour scale. Increase this to make near-zero differences read as neutral. Default 0.22.

point_alpha

Point opacity. Default 0.45.

point_size

Point size. Default 1.1.

point_outline

Logical; draw points as filled circles with a subtle neutral outline. Default TRUE.

point_outline_colour

Outline colour used when point_outline = TRUE. Default "#6B7280".

point_stroke

Outline stroke width used when point_outline = TRUE. Default 0.12.

sort

Method sort order. Use "none" to keep the supplied method order, "ascending" for smallest-to-largest values, or "descending" for largest-to-smallest values. The unadjusted raw MPD baseline remains at the right. Default "none".

sort_metric

Residual summary used when sort is not "none". Options are "median_absolute_residual", "mean_absolute_residual", and "mean_residual". Default "median_absolute_residual".

Value

A ggplot object.