This help topic is for R version 0.60.ok. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/stepfun/html/plot.stepfun.html
plot.stepfun {stepfun}R Documentation

Plot Step Functions

Description

Method of the generic plot for stepfun objects and utility for plotting piecewise constant functions.

Usage

plot.stepfun(Fn, x, xlim, 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"), ...)

Arguments

Fn

an R object inheriting from "stepfun".

x

numeric vector of abscissa values at which to evaluate Fn. Defaults to knots(Fn) restricted to xlim.

xlim

numeric(2); range of x values to use.

add

logical; if TRUE only add to an existing plot.

verticals

logical; if TRUE, draw vertical lines at steps.

do.points

logical; if true, also draw points at the (xlim restricted) knot locations.

pch

character; point character if do.points.

col.points

character or integer code; color of points if do.points.

cex.points

numeric; character expansion factor if do.points.

col.hor

color of horizontal lines.

col.vert

color of vertical lines.

xlab, ylab

labels of x and y axis.

main

main title.

...

further arguments of plot(.), or if(add) segments(.).

Value

A list with two components

t

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

y

y values ‘in between’ the t[].

See Also

ecdf for empricial distribution functions as special step functions, approxfun and splinefun.

Examples

y0 <- c(1,2,4,3)
sfun0  <- stepfun(1:3, y0, f = 0)
sfun.2 <- stepfun(1:3, y0, f = .2)
sfun1  <- stepfun(1:3, y0, f = 1)

tt <- seq(0,3, by=0.1)
op <- par(mfrow=c(2,2))
plot(sfun0); plot(sfun0, x=tt, add=T, col.h="bisque")
plot(sfun.2);plot(sfun.2,x=tt, add=T, col.h="orange")
plot(sfun1); plot(sfun1, x=tt, add=T, col.h="coral")
##-- This is  revealing :
plot(sfun0, verticals= FALSE,
     main = "stepfun(x, y0, f=f)  for f = 0, .2, 1")
for(i in 1:3)
  plot(list(sfun0,sfun.2,sfun1)[[i]], add=TRUE, col.h=i, col.v=i)
legend(2.5, 1.9, paste("f =", c(0,0.2,1)), col=1:3, lty=1, y.inter=1); par(op)

##-- this works too (automatic call to  ecdf(.)):
plot.stepfun(rt(50, df=3), col.vert = "gray20")