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

p.ts

plot.ts with multi-plots and Auto-Title – on 1 page


Description

For longer time-series, it is sometimes important to spread the time-series plots over several subplots. p.ts(.) does this both automatically, and under manual control.

Actually, this is a generalization of plot.ts (with different defaults).

Usage

p.ts(x, nrplots = max(1, min(8, n %/% 400)), overlap = nk %/% 16,
     date.x = NULL, do.x.axis = !is.null(date.x), do.x.rug = FALSE,
     ax.format, main.tit = NULL, ylim = NULL, ylab = "", xlab = "Time",
     quiet = FALSE, mgp = c(1.25, .5, 0), ...)

Arguments

x

timeseries (possibly multivariate) or numeric vector.

nrplots

number of sub-plots. Default: in {1..8}, approximately n/400 if possible.

overlap

by how much should subsequent plots overlap. Defaults to about 1/16 of sub-length on each side.

date.x

a time “vector” of the same length as x and coercable to class "POSIXct" (see DateTimeClasses).

do.x.axis

logical specifying if an x axis should be drawn (i.e., tick marks and labels).

do.x.rug

logical specifying if rug of date.x values should drawn along the x axis.

ax.format

when do.x.axis is true, specify the format to be used in the call to axis.POSIXct.

main.tit

Main title (over all plots). Defaults to name of x.

ylim

numeric(2) or NULL; if the former, specifying the y-range for the plots. Defaults to a common pretty range.

ylab, xlab

labels for y- and x-axis respectively, see description in plot.default.

quiet

logical; if TRUE, there's no reporting on each subplot.

mgp

numeric(3) to be passed to mult.fig(), see par(mgp = .).

...

further graphic parameters for each plot.ts(..).

Side Effects

A page of nrplots subplots is drawn on the current graphics device.

Author(s)

Martin Maechler, maechler@stat.math.ethz.ch; July 1994 (for S).

See Also

p.ts() calls mult.fig() for setup. Further, plot.ts and plot.

Examples

stopifnot(require(stats))
## stopifnot(require(datasets))

data(sunspots)
p.ts(sunspots, nr=1) # == usual  plot.ts(..)
p.ts(sunspots)
p.ts(sunspots, nr=3, col=2)

data(EuStockMarkets)
p.ts(EuStockMarkets[,"SMI"])
## multivariate :
p.ts(log10(EuStockMarkets), col = 2:5)

## with Date - x-axis (dense random dates):
set.seed(12)
x <- as.Date("2000-02-29") + cumsum(1+ rpois(1000, lambda= 2.5))
z <- cumsum(.1 + 2*rt(1000, df=3))
p.ts(z, 4, date.x = x)
p.ts(z, 6, date.x = x, ax.format = "%b %Y", do.x.rug = TRUE)

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.