plot.cptga: Plot Time Series with Detected Changepoints from a 'cptga'...

View source: R/cptga-class.R

plot.cptgaR Documentation

Plot Time Series with Detected Changepoints from a 'cptga' Object

Description

This function visualizes a univariate time series along with the changepoints identified by a basic genetic algorithm, as represented by a 'cptga' object. Vertical dashed lines mark changepoint locations, and segment means are shown as horizontal dashed lines. The optimal fitness value and changepoint locations are displayed as margin text.

Usage

## S3 method for class 'cptga'
plot(
  x,
  data,
  main = NULL,
  XTickLab = NULL,
  XTickPos = NULL,
  XAxisLab = "Time",
  YAxisLab = "Data",
  cex.lab = 1.3,
  cex.axis = 1.3,
  cex.main = 1.3,
  lwd = 2,
  ...
)

Arguments

x

An object of class cptgaisl, typically returned by a basic genetic algorithm based changepoint detection procedure.

data

A numeric vector representing the observed univariate time series.

main

Optional main title for the plot.

XTickLab

Optional vector (e.g., numeric or date) for custom x-axis labels. Must be the same length as data.

XTickPos

Optional vector specifying which elements of XTickLab to show as ticks.

XAxisLab

Optional label for the x-axis. Default is "Time".

YAxisLab

Optional label for the y-axis. Default is "Data".

cex.lab

Text size for axis labels and margin text. Default is 1.3.

cex.axis

Text size for axis tick labels. Default is 1.3.

cex.main

Text size for the main title. Default is 1.3.

lwd

Line width for vertical and horizontal dashed lines. Default is 2.

...

Additional graphical parameters passed to plot().

Details

If XTickLab is supplied and matches the length of data, it is used for the x-axis; otherwise, the default sequence 1:length(data) is used.

If the genetic algorithm was run with option = "both", the function skips hyperparameters in the chromosome when extracting changepoint positions.

The plot displays vertical dashed lines at changepoint locations and horizontal dashed lines for the mean of each segment. Fitness and changepoint summaries are shown above the plot.

Value

This function is called for its side effects and returns NULL invisibly.

See Also

cptga, summary, plot.cptga


changepointGA documentation built on Nov. 5, 2025, 6:54 p.m.