plot.threshold: Plot Model Fits for a 'threshold' Object

View source: R/class_plot.R

plot.thresholdR Documentation

Plot Model Fits for a 'threshold' Object

Description

S3 method for class 'threshold'. plot.threshold creates plots for objects of class threshold, using the R base plotting framework. Plots of single or multiple threshold models can be constructed.

Usage

## S3 method for class 'threshold'
plot(
  x,
  xlab = NULL,
  ylab = NULL,
  multPlot = TRUE,
  pch = 16,
  cex = 1.2,
  pcol = "black",
  ModTitle = NULL,
  TiAdj = 0,
  TiLine = 0.5,
  cex.main = 1.5,
  cex.lab = 1.3,
  cex.axis = 1,
  yRange = NULL,
  lwd = 2,
  lcol = "red",
  di = NULL,
  ...
)

Arguments

x

An object of class 'threshold'.

xlab

Title for the x-axis. Defaults will depend on any axes log-transformations.

ylab

Title for the y-axis.Defaults will depend on any axes log-transformations.

multPlot

Whether separate plots should be built for each model fit (default = TRUE) or all model fits should be printed on the same plot (FALSE)

pch

Plotting character (for points).

cex

A numerical vector giving the amount by which plotting symbols (points) should be scaled relative to the default.

pcol

Colour of the points.

ModTitle

Plot title (default is ModTitle = NULL), which reverts to the model names. For no title, use ModTitle = "".

TiAdj

Which way the plot title is justified.

TiLine

Places the plot title this many lines outwards from the plot edge.

cex.main

The amount by which the plot title should be scaled relative to the default.

cex.lab

The amount by which the axis titles should be scaled relative to the default.

cex.axis

The amount by which the axis labels should be scaled relative to the default.

yRange

The range of the y-axis. Default taken as the largest value bacross the observed and fitted values.

lwd

Line width.

lcol

Line colour. If multPlot = TRUE, just a single colour should be given, If multPlot = FALSE, either a single colour, or a vector of colours the same length as the number of model fits in x.

di

Dimensions to be passed to par(mfrow=()) to specify the size of the plotting window, when plotting multiple plots. For example, di = c(1, 3) creates a plotting window with 1 row and 3 columns. The default (NULL) creates a plotting window large enough to fit all plots in.

...

Further graphical parameters (see par, plot.default,title, lines) may be supplied as arguments.

Note

The raw lm model fit objects are returned with the sar_threshold function if the user wishes to construct their own plots.

Use par(mai = c()) prior to calling plot, to set the graph margins, which can be useful when plotting multiple models in a single plot to ensure space within the plot taken up by the individual model fit plots is maximised.

Examples

data(aegean)

#fit two threshold models (in logA-S space) and the linear and 
#intercept only models
fct <- sar_threshold(aegean, mod = c("ContOne", "DiscOne"),
                    non_th_models = TRUE,  interval = 5,
                    parallel = FALSE, logAxes = "area")

#plot using default settings
plot(fct)

#change various plotting settings, and set the graph margins prior to
#plotting
par(mai = c(0.7,0.7, 0.4, 0.3))
plot(fct, pcol = "blue", pch = 18, lcol = "green",
    ModTitle = c("A", "B", "C", "D"), TiAdj = 0.5, xlab = "Yorke")
    
#Plot multiple model fits in the same plot, with different colour for each 
#model fit
plot(fct, multPlot = FALSE, lcol = c("yellow", "red", "green", "purple"))
#Making a legend. First extract the model order:
fct[[2]]
#Then use the legend function -  note you may need to play around with the 
#legend location depending on your data.
legend("topleft", legend=c("ContOne", "DiscOne","Linear", "Intercept"), fill =
c("yellow", "red", "green", "purple"))

txm676/sars documentation built on Nov. 20, 2023, 7:29 p.m.