tsplot | R Documentation |
Produces a nice plot of univariate or multiple time series in one easy line.
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, mgpp=0, ...)
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. Input one value to apply to all margins or a vector of length 4 to add (or subtract) to the (bottom, left, top, right) 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://www.youtube.com/watch?v=b4J8VrprrGE |
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. |
mgpp |
this is used to adjust (add to) the |
... |
other graphical parameteres; see par. |
Produces a graphic and returns it invisibly so it can be saved in an R variable with the ability to replay it;
see recordPlot
.
D.S. Stoffer
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 and some help on using R for time series analysis can be found at https://nickpoison.github.io/.
## Not run: # minimal tsplot(soi) # prettified tsplot(soi, col=4, main="Southern Oscillation Index") # compare these par(mfrow=2:1) tsplot(1:453, soi, ylab='SOI', xlab='Month') # now recklessly add to the margins and add to mgp to get to the default tsplot(1:453, soi, ylab='SOI', xlab='Month', margins=c(2,3,4,5), las=1, mgpp=c(1.4,.4,0)) # gris-gris multiple plot tsplot(climhyd, ncolm=2, gg=TRUE, col=2:7, lwd=2) # spaghetti (and store it in an object - ?recordPlot for details) x <- replicate(100, cumsum(rcauchy(1000))/1:1000) u <- tsplot(x, col=1:8, main='No LLN For You', spaghetti=TRUE) u # plot on demand ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.