add.lmomco.axis: Add an lmomco Axis to a Plot

add.lmomco.axisR Documentation

Add an lmomco Axis to a Plot

Description

This function provides special support for adding probability-like axes to an existing plot. The function supports a recurrence interval (RI) axis, normal probability axis (NPP), and standard normal variate (SNV) axis. The function also supports Gumbel reduced variate (GRV) and logistic reduced variate (LRV) through the transf argument, but hereinafter “SNV” is the catch all for the other transforms (refer to Examples). The function is built around the interface model that standard normal transformation of the values for the respective axis controlled by this function are being plotted; this means that qnorm() should be wrapped on the values of nonexceedance probability. This is an ease oversight to make (see Examples section below and note use of qnorm(pp)).

The function provides a convenient interface for labeling and titling two axes, so adjustments to default margins might be desired. The pertinent control is achieved using the par() function, which might be of the form par(mgp=c(3,0.5,0), mar=c(5,4,4,3)) say for plotting the lmomco axis both on the left and right (see z.par2cdf for an example).

Usage

add.lmomco.axis(side=1, nolabels=FALSE,
                twoside=FALSE, twoside.suppress.labels=FALSE,
                side.type=c("NPP", "RI", "SNV"),
                otherside.type=c("NA", "RI", "SNV", "NPP"),
                alt.lab=NA, alt.other.lab=NA, npp.as.aep=FALSE,
                case=c("upper", "lower"),
                NPP.control=NULL, RI.control=NULL, SNV.control=NULL,
                npp.digits=3, npp.line=3, transf=c("norm", "grv", "lrv"), ...)

Arguments

side

The side of the plot (1=bottom, 2=left, 3=top, 4=right).

nolabels

A logical disabling the mtext calls internally labeling/title the axis/axes.

twoside

A logical triggering whether the tick marks are echoed on the opposite side. This value is forced to FALSE if otherside.type is not "NA".

twoside.suppress.labels

A logical to turn off labeling on the opposite side. This is useful if only the ticks (major and minor) are desired.

side.type

The axis type for the primary side.

otherside.type

The optional axis type for the opposite side. The default is a literal not applicable.

alt.lab

A short-cut to change the axis label without having to specify a *.control argument and its label attribute. The label attribute of alt.lab is not NA is used instead of the defaults. This argument overrides behavior of the otherside.type labeling so use of alt.lab only makes sense if otherside.type is left as NA.

alt.other.lab

Similar to alt.lab but can house an alternative label (see Examples.

npp.as.aep

Convert nonexceedance probability to exceedance probability, which is a que for alt.other.lab and nonexceedance probabilities are changed by 1-F, but the real coordinates for plotting remain in the nonexceedance probability context.

case

The will switch between all upper case or mixed case for the default labels.

NPP.control

An optional R list used to influence the NPP axis.

RI.control

An optional R list used to influence the RI axis.

SNV.control

An optional R list used to influence the SNV axis.

npp.digits

A convenient way to pass rounding digits into the internally built NPP.control if null on the function call. The npp.digits is passed to format(..., digits=npp.digits, nsmall=npp.digits); the user might need to adjust the digits down a couple of values as needed.

npp.line

A convenient way to pass the line in mtext into the internally built NPP.control if null on the function call.

transf

A character string identify the probability transform and casting to lowercase also is made internally to accommodate uppercase for the argument.

...

Additional arguments that are passed to the R function Axis.

Value

No value is returned. This function is used for its side effects.

Note

The NPP.control, RI.control, and SNV.control are R list structures that can be populated (and perhaps someday extended) to feed various settings into the respective axis types. In brief:

The NPP.control provides

label The title for the NPP axis---be careful with value of as.exceed.
probs A vector of nonexceedance probabilities F.
probs.lab A vector of nonexceedance probabilities F to label.
digits The digits for the R function format to enhance appearance.
line The line for the R function mtext to place label.
as.exceed A logical triggering S = 1 - F.

The RI.control provides

label The title for the RI axis.
Tyear A vector of T-year recurrence intervals.
line The line for the R function mtext to place label.

The SNV.control provides

label The title for the SNV axis.
begin The beginning “number of standard deviations”.
end The ending “number of standard deviations”.
by The step between begin and end.
line The line for the R function mtext to place label.

The user is responsible for appropriate construction of the control lists. Very little error trapping is made to keep the code base tight. The defaults when the function definition are likely good for many types of applications. Lastly, the manipulation of the mgp parameter in the example is to show how to handle the offset between the numbers and the ticks when the ticks are moved to pointing inward, which is opposite of the default in R.

Author(s)

W.H. Asquith

See Also

prob2T, T2prob, add.log.axis, prob2grv, prob2lrv

Examples

## Not run: 
  n <- 2000; ff <- runif(n); ylab <- "X"
  pnor <- parnor(vec2lmom(c(0, 1, 0)))
  pgum <- pargum(vec2lmom(c(0, 1, log(9/8) / log(2))))
  pglo <- parglo(vec2lmom(c(0, 1, 0)))
  xnor <- sort(qlmomco(ff, pnor))
  xgum <- sort(qlmomco(ff, pgum))
  xglo <- sort(qlmomco(ff, pglo))
  xlim <- c(0.001, 0.999); ylim <- range(c(xnor, xgum, xglo)); tcl <- 0.5
  par(mgp=c(3,0.5,0), mai=c(1.02, 0.82, 1.02, 0.42))
  tf <- qnorm # We will have the random values from the normal plotted on top.
  plot(  tf(pp(xgum)), xgum, xaxt="n", xlab="", xlim=tf(xlim),
                                       ylab=ylab,  ylim=ylim, col="green4")
  add.lmomco.axis(las=2, tcl=tcl, side.type="RI", otherside.type="NPP", transf="norm")
  points(tf(pp(xglo)), xglo, col="salmon2"); points(tf(pp(xnor)), xnor, col="black")
  mtext("Standard Normal Variate", side=1, line=3, col="black", font=2)

  tf <- prob2grv # We will have the random values from the Gumbel plotted on top.
  plot(  tf(pp(xnor)), xnor, xaxt="n", xlab="", xlim=tf(xlim),
                                       ylab=ylab,  ylim=ylim)
  add.lmomco.axis(las=2, tcl=tcl, side.type="RI", otherside.type="NPP", transf="grv")
  points(tf(pp(xglo)), xglo, col="salmon2"); points(tf(pp(xgum)), xgum, col="green4")
  mtext("Gumbel reduced variate", side=1, line=3, col="green4", font=2)

  tf <- prob2lrv # We will have the random values from the GLO plotted on top.
  plot(  tf(pp(xnor)), xnor, xaxt="n", xlab="", xlim=tf(xlim),
                                       ylab=ylab,  ylim=ylim)
  add.lmomco.axis(las=2, tcl=tcl, side.type="RI", otherside.type="NPP", transf="lrv")
  points(tf(pp(xgum)), xgum, col="green4"); points(tf(pp(xglo)), xglo, col="salmon2")
  mtext("Logistic reduced variate", side=1, line=3, col="salmon2", font=2)
  par(mgp=c(3,1,0), mai=c(1.02, 0.82, 0.82, 0.42)) #
## End(Not run)

## Not run: 
  opts <- options(scipen=6); par(mgp=c(3,0.5,0))
  X <- sort(rexp(65, rate=.0001))*100; pp <- pp(X) # generate synthetic data
  plot(qnorm(pp), X, yaxt="n", xaxt="n", xlab="", ylab="", log="y")
  add.log.axis(side=2,    tcl=+0.8*abs(par()$tcl),         two.sided=TRUE)
  add.log.axis(logs=c(1), tcl=-0.5*abs(par()$tcl), side=2, two.sided=TRUE)
  add.log.axis(logs=c(1), tcl=+1.3*abs(par()$tcl), side=2, two.sided=TRUE)
  add.log.axis(logs=1:8, side=2, make.labs=TRUE, las=1, label="QUANTILE")
  add.lmomco.axis(las=2, tcl=0.5, side.type="NPP", npp.as.aep=TRUE, case="lower",
                  npp.digits=2, npp.line=4)
  options(opts)
  par(mgp=c(3,1,0)) # restore defaults
## End(Not run)

lmomco documentation built on Oct. 18, 2026, 5:07 p.m.