Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plotStep

Plot a Step Function


Description

Plots a step function f(x)= sum(i; y[i] * Ind[t[i-1], t[i])(x)), i.e., a piecewise constant function of one variable. With one argument, plots the empirical cumulative distribution function.

Usage

plotStep(ti, y,
          cad.lag = TRUE,
          verticals = !cad.lag,
          left.points= cad.lag, right.points= FALSE, end.points= FALSE,
	  add = FALSE,
	  pch = par('pch'),
          xlab=deparse(substitute(ti)), ylab=deparse(substitute(y)),
          main=NULL, ...)

Arguments

ti

numeric vector = X[1:N] or t[0:n].

y

numeric vector y[1:n]; if omitted take y = k/N for empirical CDF.

cad.lag

logical: Draw 'cad.lag', i.e., “continue à droite, limite à gauche”. Default = TRUE.

verticals

logical: Draw vertical lines? Default= ! cad.lag

left.points

logical: Draw left points? Default= cad.lag

right.points

logical: Draw right points? Default= FALSE

end.points

logical: Draw 2 end points? Default= FALSE

add

logical: Add to existing plot? Default= FALSE

pch

plotting character for points, see par().

xlab,ylab

labels of x- and y-axis

main

main title; defaults to the call' if you do not want a title, use main = "".

...

Any valid argument to plot(..).

Value

invisibly: List with components t and y.

Side Effects

Calls plot(..), points(..), segments(..) appropriately and plots on current graphics device.

Author(s)

Martin Maechler, Seminar for Statistics, ETH Zurich, maechler@stat.math.ethz.ch, 1991 ff.

See Also

The plot methods plot.ecdf and plot.stepfun in R which are conceptually nicer.

segments(..., method = "constant").

Examples

##-- Draw an Empirical CDF  (and see the default title ..)
plotStep(rnorm(15))

plotStep(runif(25), cad.lag=FALSE)
plotStep(runif(25), cad.lag=FALSE, add=TRUE, lty = 2)

ui <- sort(runif(20))
plotStep(ui, ni <- cumsum(rpois(19, lambda=1.5) - 1.5), cad.lag = FALSE)
plotStep(ui, ni, verticals = TRUE, right.points = TRUE)

plotStep(rnorm(201), pch = '.') #- smaller points

sfsmisc

Utilities from 'Seminar fuer Statistik' ETH Zurich

v1.1-11
GPL (>= 2)
Authors
Martin Maechler [aut, cre] (<https://orcid.org/0000-0002-8685-9910>), Werner Stahel [ctb] (Functions: compresid2way(), f.robftest(), last(), p.scales(), p.dnorm()), Andreas Ruckstuhl [ctb] (Functions: p.arrows(), p.profileTraces(), p.res.2x()), Christian Keller [ctb] (Functions: histBxp(), p.tachoPlot()), Kjetil Halvorsen [ctb] (Functions: KSd(), ecdf.ksCI()), Alain Hauser [ctb] (Functions: cairoSwd(), is.whole(), toLatex.numeric()*), Christoph Buser [ctb] (to function Duplicated()), Lorenz Gygax [ctb] (to function p.res.2fact()), Bill Venables [ctb] (Functions: empty.dimnames(), primes()), Tony Plate [ctb] (to inv.seq()), Isabelle Fl<fc>ckiger [ctb], Marcel Wolbers [ctb], Markus Keller [ctb], Sandrine Dudoit [ctb], Jane Fridlyand [ctb], Greg Snow [ctb] (to loessDemo()), Henrik Aa. Nielsen [ctb] (to loessDemo()), Vincent Carey [ctb], Ben Bolker [ctb], Philippe Grosjean [ctb], Fr<e9>d<e9>ric Ibanez [ctb], Caterina Savi [ctb], Charles Geyer [ctb], Jens Oehlschl<e4>gel [ctb]
Initial release
2021-04-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.