tisPlot is a function with dozens of options for creating
high quality time series plots. Can be used with screenPage.tisPlot(...,
leftAxis = TRUE, plotType = "l",
lineType = "solid", lineWidth = 1.5,
plotChar = "*", dataCex = 1, color = 1,
midPoints = TRUE, dropNA = FALSE, xOffset = 0,
xAxisMin = NULL, xAxisMax = NULL, xExpandBy = 0.04,
xTickFreq = "Auto", xTickSkip = 0,
xUnlabeledTickFreq = "None", xUnlabeledTickSkip = 0,
xMinorTickFreq = "None", xMinorTickSkip = 0,
dateFormat = "Auto", xCex = 1,
midLabels = FALSE, yearLabels = FALSE,
xAxisLabel = NULL, xSpace = 4, log = FALSE,
leftAxisMin = NULL, leftAxisMax = NULL, leftExpandBy = 0.04,
leftTicks = 5, leftTickLocations = NULL,
labelLeftTicks = FALSE, leftTickLabels = NULL,
rightAxisMin = NULL, rightAxisMax = NULL, rightExpandBy = 0.04,
rightTicks = 5, rightTickLocations = NULL,
labelRightTicks = TRUE, rightTickLabels = NULL,
yCex = 1, extendTopTick = TRUE,
cex = 1,
head = NULL, headAlign = 0.5, headCex = 1.5,
sub = NULL, subCex = 0.85,
leftTopLabel = NULL, rightTopLabel = NULL, topLabelAlign = 0,
labCex = 1,
leftInsideLabel = NULL, rightInsideLabel = NULL,
innerLine = 0.5, innerOffset = 0.05, innerCex = 0.8,
foot = NULL, footColor = "black", footAlign = 0,
footCex = 0.8, footSpace = -1,
tck = 0.03,
axisWidth = 2,
start = 0, end = 0,
boxType = "u",
leftMargin = -1, rightMargin = -1, topMargin = -1, bottomMargin = -1,
nberShade = FALSE, nberColor = "gray", nberBorder = FALSE, nberArgs = list())tis series to be plotted.
Non-tis arguments will be converted by as.tis.leftAxis[i] = TRUE means plot the i'th series
against the left axis, otherwise plot it against the right axis."p" for points, "l"
for lines, "b" for both points and lines (lines miss the
points), and "o" for overlaid points and lines.1:nSeries, where nSeries is the
number of series being plotted. Normally type 1 is solid,
2 is dotted, 3 and up ar1.5.points for details) to be used for plotting
points.
Default is "*".cex times these numbers give the character
expansion factor for the data points. Default is 1.midPoints[i] = TRUE aligns the data points of the i'th
series with the middle day of the periods in which they fall,
otherwise data points are aligned with the last day of their periods.TRUE, observations with NA values are
dropped before calling lines.default to draw the lines and/or
points on the plot. See the details section of the help for
lines.tisxOffset[i] days. This argument is replicated to be as long
as the number of series.xExpandBy.xExpandBy.xAxisMin and xAxisMax by multiplicatively
extending the data range in both directions by this amount. Default
value .04 extends the data range by 4% in each direction.tifName. This argument and
xTickSkip jointly specify locations for labeled x axis ticks
as follow: (i) find the ti's of the given frequency that
correspond to xAxisMinxTickFreq to specify location of labeled
tick marks. The default is zero.xTickFreq, but for unlabeled major tick locations.xTickSkip, but for unlabeled major tick locations.xTickFreq, but for minor tick locations.xTickSkip, but for minor tick locations.strftime for
formats. Default value "auto" tries to come up with a reasonable
format automatically, for some bounded value of "reasonable".cex times this number gives the character expansion factor
for the x-axis labels. Default is 1.TRUE (the default) x axis label are centered between the
ticks they label; if FALSE the label alignment depends on the
setting of midPoints. If midPoints is TRUE,
the labels (whiTRUE place year labels centered under the x ticks they
span. The default is FALSE.xAxisLabel is not supported. No
default.4. The space
created is xSpace times labCex.TRUE use log scaling for y axes. Default is FALSE.leftExpandBy.leftExpandBy.leftAxisMin and leftAxisMax by multiplicatively
extending the data range of the leftAxis series in both directions
by this amount. Default value .04 extends the data range by 4% in
each direction.leftTickLocations is
non-NULL.leftTicks take effect.TRUE, label ticks on the left axis. Default is FALSE.labelLeftTicks is TRUE, labels are constructed from
the tick locations. This argument has no effect if
labelLeftTicks is FALSE.rightExpandBy.rightExpandBy.rightAxisMin and rightAxisMax by multiplicatively
extending the data range of the rightAxis series in both directions
by this amount. Default value .04 extends the data range by 4% in
each direction.rightTickLocations is non-NULL.rightTicks take effect.TRUE, label ticks on the right axis. Default is FALSE.labelRightTicks is TRUE, labels are constructed from
the tick locations. This argument has no effect if
labelRightTicks is FALSE.cex times this number gives the character expansion factor
for the left and right axis labels. Default is 1.TRUE (the default) the top tick of the y axes encloses the
panel. leftAxisMax and rightAxisMax are increased as
necessary to include the top tick for enclosing the panel.***cex parameters are scaled. The default setting is the
value of par("cex").headAlign. No default.head and
sub. 0 means left justify, 1 means right
justify, 0.5 (the default) means to center the text. Other
numbers are a correspondincex times this number gives the character expansion factor
for head. Default is 1.5.head, with alignment determined by
headAlign. No default.cex times this number gives the character expansion factor
for sub. Default is 0.85.topLabelAlign. No default.topLabelAlign. No default.leftTopLabel.
0 (the default) means left justify, 1 means right
justify, 0.5 means to center the text. rightTopLabel,
if given, is aligned cex times this number gives the character expansion factor
for leftTopLabel, rightTopLabel, and xAxisLabel.leftInsideLabel is offset by this fraction
of the x range from the left edge of the plot, as is the right edge
of rightInsideLabel from the ricex times this number gives the character expansion factor
for leftInsideLabel and rightInsideLabel.footAlign. Use a vector of character strings to
get several footnotes. No default.foot.
0 (the default) means left justify, 1 means right
justify, 0.5 means to center the text. Other numbers are a
corresponding distance between thcex times this number gives the character expansion factor
for foot. Default is 0.8.foot, specifying the
color for each footnote. Default is 1, the device default foreground
color. The elements of this argument are cyclically repeated, if
necessary, to make footColor thxSpace to hold footnotes. The space created is
footSpace times footCex. Default is
length(foot); using a higher value will result ixTick, xUnlabeledTick and side tick
marks as a fraction of the smaller of the width or height of the
plotting region. Minor ticks (xMinorTicks) are 2/3 as long.
If tck >= 0.5 it is inteti().ti()."o",
"l" (ell), "7", "c" will produce boxes which
resemble the corresponding upper-case letters. The value "n"
will suppress boxes. The TRUE, call the nberShade function to shade
recession periods on the plot. The default is FALSE.nberShade is
TRUE. Passed along to the nberShade function.TRUE and nberShade is also TRUE, draws
borders on the NBER shaded areas. Default is FALSE.nberShade function
if nberShade is TRUE.tisPlot invisibly returns a list of class "tisPlot" and
elements named series, dateFormat, plotType,
lineType, dataCex, color, plotChar,
lineWidth, yLegendOffset, cex, xRange,
leftRange, rightRange, midPoints and par.
This list is useful mostly as an argument to tisLegend.leftAxis, plotType, lineType, lineWidth,
plotChar, dataCex, color and midPoints are
all cyclically repeated to make them length nSeries, the number
of series plotted. Each of the text items head, sub, leftTopLabel,
rightTopLabel, leftInsideLabel, rightInsideLabel,
foot, and xAxisLabel can be given as a string, a
collections of strings, or as a string that gets evaluated to one of
the first two. (But xAxisLabel takes only a single string.)
See the help details for evalOrEcho to see how this works.
evalOrEcho, scatterPlot,
tisLegend, nberShadefirstTis <- tis(cumsum(rnorm(120)), start = c(1996,1), freq = 12)
secondTis <- tis(cumsum(rnorm(120)), start = c(1996,1), freq = 12)
tisPlot(firstTis, secondTis, color = c("red", "green"),
lineType = "solid", head = "Two Random Walks")
tisLegend(legend = c("Random Walk 1", "Random Walk 2"))
series <- tis(cumsum(rnorm(200)), start = c(1960,1), tif = "quarterly")
tisPlot(series, xMinorTickFreq = "annual", nberShade = TRUE,
head = "A Random Walk", sub = "Looks like an econ series",
rightTopLabel = "$Billions")
romerLines()Run the code above in your browser using DataLab