Regular time series, time series matrices or ordinary
vectors, dataframes or matrices with values corresponding to regular
time intervals. Corresponding axes are on the left (for y1)
and on the right (for y2) respectively. y2 is optional
and may have a different frequency and a different start time.
names1, names2
Names for time series used for legend.
startP
Start time of plot.
upf
Number of time units plottet per figure.
fpp
Number of figures per page (screen).
overlap
Length of time series on the right end of the figures
which is identical with the left start of the next figure.
x.at
Time points at which long ticks on x-axis and annotations
are set.
x.ann
Time annotations (character vector) for long ticks on
x-axis
x.tick
Time points at which short ticks are set on x-axis. If
Null, no short ticks are set.
y1.at, y1.ann, y1.tick, y2.at, y2.ann, y2.tick
Arguments
starting with 'y1' ('y2') correspond to arguments for left (right)
axis. For details see arguments for x-axis.
nx.ann, ny.ann
Approximate number of annotations on x- and
y-axes, respectively
cex.ann
The magnification to be used for axis annotation
relative to the current setting of cex.
xlab
Label for x-axis.
y1lab, y2lab
Labels for y-axes on the left and on the right
end of the figure.
las
Cf. par.
col.y1, col.y2
Colors for left and right axis respectively.
cex.lab
cex of labels.
y1lim, y2lim
Limits for left and right axis respectively.
lty1, lty2
Vector of line types for each time series, possibly
recycled.
lwd1, lwd2
Vector of line widths for each time series,
possibly recycled.
col1, col2
Vector of color for each time series, possibly
recycled.
leg
Logical. When TRUE, legend is drawn.
y1nam.leg, y2nam.leg
Name of y1- and y2-axis in legend.
ncol.leg
Number of columns in legend.
cex.leg
cex for legend.
h1, h2
Vector of y-positions of horizontal lines in the
coordinate systems represented by the left and the right axis
respectively.
col.h1, col.h2
Vector of colors for horizontal lines.
main
Title of plot.
cex.main
cex of title.
automain
Logical. When TRUE, the units of the start and
the end on the page are printed in the title.
mgp, mar, oma
Cf. par.
xpd
Define whether data points are clipped to the plot region
(=FALSE) or not (=TRUE). Horizontal lines, defined by h1 or
h2 are always clipped.
cex
Cf. par.
type1, type2
For plotting lines or
points. Cf. plot.
pch1, pch2, cex.pt1, cex.pt2
Plotting symbols and there sizes
when 'type1' or 'type2' = "p"
slide
Logical. When FALSE, the first page (screen) is
plotted only. When TRUE, user may leaf through the pages
interactively.
each.fig
For each.fig==1 all data are plotted.
for each.fig==2 every 2nd page is plotted and
so on.
filename
When filename is not
NULL, the displayed screen(s) are saved to
disk and there is no question whether the next page should be
printed. When slide = TRUE, the filename of the plots is
extended by a serial number.
extension
The extension is defined automatically
on windows systems and must be defined manually on the other
systems.
filetype
On Windows:
The type of plot, Windows metafile, PNG, JPEG,
BMP (Windows bitmap format), TIFF, PostScript or PDF.
Defaults to Windows meta file, "wmf" ,
with the extension ".wmf".
Cf. savePlot.
On non Windows operating systems: A device
function (e.g., x11, postscript,...). The filetype
defaults to postscript , with the extension
".ps". Cf. dev.print
...
Additional arguments to
savePlot and
dev.print respectively.
Details
For longer time-series, it is sometimes important to spread several
time-series plots over several subplots or even over several pages
with several subplots in each. Moreover, these series have often
different ranges, frequencies and start times. There is sometimes also
the need of a more flexible annotation of axes than plot.ts
provides. longtsPlot provides the user with all these features
for one or two matrices or regular time series (time series matrices).
Side Effects
One or more pages of time series plots are drawn on the current
graphic device and, optionally, saved in one or more files.
Author(s)
Rene Locher
Examples
## sunspots, y-axis only on the left
data(sunspots)
longtsPlot(sunspots,upf=ceiling((end(sunspots)-start(sunspots))[1]/5))
## air quality (left axis) and meteo data (right axis)
## use xpd=TRUE for time series with rare but large values
if (require(SwissAir)) {
data(AirQual)
st <- 6.5*30*48
x.at <- seq(st,nrow(AirQual),48)
longtsPlot(y1=AirQual[,c("ad.O3","ad.NOx")], y2 = AirQual$ad.T,
names1=c("O3","NOx"),names2 = "Temp",
startP = st, upf=7*48,
x.at = x.at, x.ann = substr(AirQual$start,1,6)[x.at],
x.tick = seq(st,nrow(AirQual),12),
y1.at = c(0,100), y1.tick = seq(0,150,50),
y2.at = c(10,30), y2.tick = seq(10,30,10),
y1lab="[ppb]", y2lab="[C]",
y1lim = c(0,100), y2lim = c(10,30), xpd=TRUE,
col2 = "red", type1 = "l")
}
## Two time series with different frequencies and start times
## on the same figures
set.seed(13)
len <- 4*6*400
x <- sin((1:len)/200*pi)
d <- sin(cumsum(1+ rpois(len, lambda= 2.5)))
y1 <- ts(10*x,start=0,frequency=6)+d*rnorm(len)
y2 <- ts(100*x,start=100,frequency=13)+10*rnorm(len)
longtsPlot(y1,y2)
## plot your own legend
longtsPlot(sunspots,upf=ceiling((end(sunspots)-start(sunspots))[1]/5),
fpp=1, leg=FALSE)
legend(1750,260,legend="Monthly Sunspot Numbers",col="blue",lwd=1,
bty="n")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(IDPmisc)
Loading required package: grid
Loading required package: lattice
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IDPmisc/longtsPlot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: longtsPlot
> ### Title: Plot Very Long Regular Time Series
> ### Aliases: longtsPlot
> ### Keywords: hplot iplot ts multivariate
>
> ### ** Examples
>
> ## sunspots, y-axis only on the left
> data(sunspots)
> longtsPlot(sunspots,upf=ceiling((end(sunspots)-start(sunspots))[1]/5))
>
> ## air quality (left axis) and meteo data (right axis)
> ## use xpd=TRUE for time series with rare but large values
> if (require(SwissAir)) {
+ data(AirQual)
+ st <- 6.5*30*48
+ x.at <- seq(st,nrow(AirQual),48)
+ longtsPlot(y1=AirQual[,c("ad.O3","ad.NOx")], y2 = AirQual$ad.T,
+ names1=c("O3","NOx"),names2 = "Temp",
+ startP = st, upf=7*48,
+ x.at = x.at, x.ann = substr(AirQual$start,1,6)[x.at],
+ x.tick = seq(st,nrow(AirQual),12),
+ y1.at = c(0,100), y1.tick = seq(0,150,50),
+ y2.at = c(10,30), y2.tick = seq(10,30,10),
+ y1lab="[ppb]", y2lab="[C]",
+ y1lim = c(0,100), y2lim = c(10,30), xpd=TRUE,
+ col2 = "red", type1 = "l")
+ }
Loading required package: SwissAir
>
> ## Two time series with different frequencies and start times
> ## on the same figures
> set.seed(13)
> len <- 4*6*400
> x <- sin((1:len)/200*pi)
> d <- sin(cumsum(1+ rpois(len, lambda= 2.5)))
>
> y1 <- ts(10*x,start=0,frequency=6)+d*rnorm(len)
> y2 <- ts(100*x,start=100,frequency=13)+10*rnorm(len)
> longtsPlot(y1,y2)
>
> ## plot your own legend
> longtsPlot(sunspots,upf=ceiling((end(sunspots)-start(sunspots))[1]/5),
+ fpp=1, leg=FALSE)
> legend(1750,260,legend="Monthly Sunspot Numbers",col="blue",lwd=1,
+ bty="n")
>
>
>
>
>
> dev.off()
null device
1
>