Learn R Programming

astsa (version 1.15)

tsplot: Time Series Plot

Description

Produces a nice plot of univariate or multiple time series in one easy line.

Usage

tsplot(x, y=NULL, main=NULL, ylab=NULL, xlab='Time', type=NULL,
        margins=.25, ncolm=1, byrow=TRUE, minor=TRUE, nxm=2, nym=1,
        xm.grid=TRUE, ym.grid =TRUE, col=1, gg=FALSE, spaghetti=FALSE,
        pch=NULL, lty=1, lwd=1, ...)

Arguments

x, y

time series to be plotted; if both present, x will be the time index.

main

add a plot title - the default is no title.

ylab

y-axis label - the default is the name of the ts object.

xlab

x-axis label - the default is 'Time'.

type

type of plot - the default is line.

margins

inches to add (or subtract) to the margins.

ncolm

for multiple time series, the number of columns to plot.

byrow

for multiple time series - if TRUE (default), plot series row wise; if FALSE, plot series column wise.

minor, nxm, nym

if minor=TRUE, the number of minor tick marks on x-axis, y-axis. minor=FALSE removes both or set either to 0 or 1 to remove. The default is one minor tick on the x-axis and none on the y-axis.

xm.grid, ym.grid

if TRUE (default), adds grid lines at minor x-axis, y-axis ticks.

col

line color(s), can be a vector for multiple time series.

gg

if TRUE, will produce a gris-gris plot (gray graphic interior with white grid lines); the default is FALSE. The grammar of astsa is voodoo;
see https://musicaficionado.blog/2017/11/08/gris-gris-by-dr-john/

spaghetti

if TRUE, will produce a spaghetti plot (all series on same plot).

pch

plot symbols (default is 1, circle); can be a vector for multiple plots.

lty

line type (default is 1, solid line); can be a vector for multiple plots.

lwd

line width (default is 1); can be a vector for multiple plots.

...

other graphical parameteres; see par.

Author

D.S. Stoffer

References

You can find demonstrations of astsa capabilities at FUN WITH ASTSA.

The most recent version of the package can be found at https://github.com/nickpoison/astsa/.

In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.

The webpages for the texts are https://www.stat.pitt.edu/stoffer/tsa4/ and https://www.stat.pitt.edu/stoffer/tsda/.

Examples

Run this code
if (FALSE) {
tsplot(soi, col=4, main="Southern Oscillation Index")
#
tsplot(1:453, soi, ylab='SOI', xlab='Month')
#
tsplot(climhyd, ncolm=2, gg=TRUE, col=2:7, lwd=2)  # gris-gris plot
#
x <- replicate(100, cumsum(rcauchy(1000))/1:1000)
tsplot(x, col=1:8, main='No LLN For You', spaghetti=TRUE)
}

Run the code above in your browser using DataLab