setpar {onlineforecast}R Documentation

Setting par() plotting parameters

Description

Setting par() plotting parameters to a set of default values

Usage

setpar(tmpl = "ts", mfrow = c(1, 1), ...)

Arguments

tmpl

The name of the parameter template, give "ts" as default

mfrow

The mfrow for par.

...

More parameters for par.

Details

A simple function, which sets the par() plotting parameters to a default set of values.

Actually, only really used for setting useful par values for multiple time series plots with same x-axis. Give tmpl="ts" and mfrow=c(x,1), where x is the number of plots.

Value

Return the original set of parameters, such that they can be reset after plotting.

Examples


# Make some data
D <- data.frame(t=seq(ct("2020-01-01"),ct("2020-01-10"),len=100), x=rnorm(100), y=runif(100))
# Remember the currect par values
oldpar <- setpar()

# Generate two stacked plots with same x-axis
setpar("ts", mfrow=c(2,1))
plot(D$t, D$x, type="l")
plot(D$t, D$y, type="l")
# Note xaxt="s" must be set
axis.POSIXct(1, D$t, xaxt="s", format="%Y-%m-%d")

# Set back the par to the previous
par(oldpar)

# In a function, where this is used and a plot is generated,
# then do like this in order to automatically reset on exit
oldpar <- setpar(mfrow=c(2,1))
on.exit(par(oldpar))        


[Package onlineforecast version 1.0.2 Index]