psi.plot.stepfun: Plot piecewise constant functions

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Plot a stepfun object. The function is a modification of plot.stepfun from package stats but has an additional argument to force the domain of x-values rigidly.

Usage

1
2
3
4
5
6
7
psi.plot.stepfun(x, xval, xlim, ylim = range(c(y, Fn.kn)),
    xlab = "x", ylab = "f(x)", main = NULL,
    add = FALSE, verticals = TRUE, do.points = TRUE,
    pch = par("pch"), col.points = par("col"), cex.points = par("cex"),
    col.hor = par("col"), col.vert = par("col"),
    lty = par("lty"), lwd = par("lwd"),
    rigid.xlim = FALSE, ...)

Arguments

x

an R object inheriting from '"stepfun"', usually created by stepfun

xlim

numeric(2), range of 'x' values to use, has sensible defaults.

add

logical; if 'TRUE' only add to an existing plot.

verticals

logical; if 'TRUE', draw vertical lines at steps.

rigid.xlim

If TRUE respect xlim rigidly, see details.

xval

see help page of plot.stepfun.

ylim

see help page of plot.stepfun.

xlab

see help page of plot.stepfun.

ylab

see help page of plot.stepfun.

main

see help page of plot.stepfun.

do.points

see help page of plot.stepfun.

pch

see help page of plot.stepfun.

col.points

see help page of plot.stepfun.

cex.points

see help page of plot.stepfun.

col.hor

see help page of plot.stepfun.

col.vert

see help page of plot.stepfun.

lty

see help page of plot.stepfun.

lwd

see help page of plot.stepfun.

...

see help page of plot.stepfun.

Details

The default method for plotting stepfun objects extends slightly the domain requested by xlim. This is not always desirable, especially if the function is not defined outside the specified limits. This function has all the arguments of plot.stepfun and does the same job with the additional option to force the use of xlim as given by setting the argument rigid.xlim to TRUE.

Value

A list with two components

t

abscissa (x) values, including the two outermost ones.

y

y values ‘in between’ the ‘t[]’.

Note

This function is a modification of plot.stepfun from the stats package as supplied with R~2.8.1. Some of the text in this help page has been taken from the help page of plot.stepfun.

Author(s)

Georgi N. Boshnakov (to be blamed for bugs; the credits should go to the R core team)

References

R package "stats" for the code of the original plot.stepfun.

See Also

plot.stepfun, stepfun

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# define  empirical quantile functon as a step function.
eqf <- function(x) stepfun((1:(length(x)))/length(x),c(x,NA),right=TRUE)

# create eqf for a random sample.
x <- sort(rnorm(10))
f1 <- eqf(x)

# plot f1
psi.plot.stepfun(f1,xlim=c(0,1),rigid.xlim=TRUE)
psi.plot.stepfun(f1,xlim=c(0,1),rigid.xlim=TRUE,verticals=FALSE)
psi.plot.stepfun(f1,xlim=c(0,1),rigid.xlim=TRUE,verticals=FALSE,
                 main="An emprirical qf")

psi.plot.stepfun(f1,xlim=c(0,1),rigid.xlim=TRUE,pch=19,verticals=FALSE)

# plot(f1) would give an error because of the NA, so modify.
eqf2 <- function(x) stepfun((1:(length(x)))/length(x),c(x,0),right=TRUE)
f2 <- eqf2(x)

# the default method for stepfun plots outside the domain of eqf.
plot(f2,xlim=c(0,1),verticals=FALSE)

# eqf's with overlaid qf's
psi.plot.stepfun(f1,xlim=c(0,1),rigid.xlim=TRUE,pch=19,verticals=FALSE)
curve(qnorm,add=TRUE, col="red")

psi.plot.stepfun(eqf(sort(rnorm(100))),xlim=c(0,1),rigid.xlim=TRUE,
                 pch=19,verticals=FALSE,do.points=FALSE)
curve(qnorm,add=TRUE, col="red")

GeoBosh/psistat documentation built on Nov. 19, 2020, 8:19 p.m.