plot.source_detection: Visualize Source Detection Results

View source: R/plot_source_detect.R

plot.source_detectionR Documentation

Visualize Source Detection Results

Description

S3 plot method for objects of class "source_detection". Produces a bar chart of the T-index for each source dataset, with bars extending from a solid baseline at zero and a horizontal reference line at the transferability threshold. Sources whose T-index falls on or below the threshold are considered transferable.

Usage

## S3 method for class 'source_detection'
plot(
  x,
  fill_transferable = "white",
  fill_nontransferable = "white",
  color = "black",
  linewidth = 0.5,
  size.text = 3,
  show.values = TRUE,
  digits = 3,
  base_size = 12,
  threshold.linetype = "dashed",
  threshold.color = "gray30",
  ...
)

Arguments

x

An object of class "source_detection", returned by source_detection.

fill_transferable

Fill color for transferable-source bars. Default is "white".

fill_nontransferable

Fill color for non-transferable-source bars. Default is "white".

color

Bar border color. Default is "black".

linewidth

Bar border line width. Default is 0.5.

size.text

Numeric; size of value labels on bars. Default is 3.5.

show.values

Logical; if TRUE (default), T-index values are displayed on each bar.

digits

Integer; number of decimal places for displayed values. Default is 3.

base_size

Numeric; base font size passed to theme_classic. Default is 12.

threshold.linetype

Linetype for the threshold reference line. Default is "dashed".

threshold.color

Color for the threshold reference line. Default is "gray30".

...

Additional arguments (currently unused).

Value

A ggplot object.

See Also

source_detection

Examples


set.seed(123)
target_data <- data.frame(
  Y  = rnorm(200), D  = rnorm(200),
  M1 = rnorm(200), M2 = rnorm(200), X1 = rnorm(200)
)
source1 <- data.frame(
  Y  = rnorm(300), D  = rnorm(300),
  M1 = rnorm(300), M2 = rnorm(300), X1 = rnorm(300)
)
source2 <- data.frame(
  Y  = rnorm(250), D  = rnorm(250),
  M1 = rnorm(250), M2 = rnorm(250), X1 = rnorm(250)
)
result <- source_detection(
  target_data = target_data,
  source_data = list(source1, source2),
  Y = "Y", D = "D", M = c("M1", "M2"), X = "X1",
  kfold = 5, verbose = FALSE
)
plot(result)



TransHDM documentation built on Nov. 24, 2026, 9:06 a.m.