\HeaderA{chart.TimeSeries}{Creates a time series chart with some extensions.}{chart.TimeSeries}
\keyword{ts}{chart.TimeSeries}
\keyword{multivariate}{chart.TimeSeries}
\keyword{distribution}{chart.TimeSeries}
\keyword{models}{chart.TimeSeries}
\keyword{hplot}{chart.TimeSeries}
\begin{Description}\relax
Draws a line chart and labels the x-axis with the appropriate dates.  This is really a "primitive", since it extends the base \code{\LinkA{plot}{plot}} and standardizes the elements of a chart.  Adds attributes for shading areas of the timeline or aligning vertical lines along the timeline. This function is intended to be used inside other charting functions.
\end{Description}
\begin{Usage}
\begin{verbatim}
chart.TimeSeries(R, auto.grid = TRUE, xaxis = TRUE, yaxis = TRUE, yaxis.right = FALSE, type = "l", lty = 1, lwd = 2, main = NULL, ylab = NULL, xlab = "Date", date.format.in = "%Y-%m-%d", date.format = NULL, xlim = NULL, ylim = NULL, element.color = "darkgray", event.lines = NULL, event.labels = NULL, period.areas = NULL, event.color = "darkgray", period.color = "aliceblue", colorset = (1:12), pch = (1:12), legend.loc = NULL, ylog = FALSE, cex.axis = 0.8, cex.legend = 0.8, cex.lab = 1, cex.labels = 0.8, cex.main = 1, major.ticks = "auto", minor.ticks = TRUE, grid.color = "lightgray", grid.lty = "dotted", xaxis.labels = NULL, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{R}] an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns 
\item[\code{auto.grid}] if true, draws a grid aligned with the points on the x and y axes 
\item[\code{grid.color}] sets the color for the reference grid 
\item[\code{grid.lty}] defines the line type for the grid 
\item[\code{xaxis}] if true, draws the x axis 
\item[\code{yaxis}] if true, draws the y axis 
\item[\code{yaxis.right}] if true, draws the y axis on the right-hand side of the plot 
\item[\code{type}] set the chart type, same as in \code{\LinkA{plot}{plot}} 
\item[\code{lty}] set the line type, same as in \code{\LinkA{plot}{plot}} 
\item[\code{lwd}] set the line width, same as in \code{\LinkA{plot}{plot}} 
\item[\code{main}] set the chart title, same as in \code{\LinkA{plot}{plot}} 
\item[\code{ylab}] set the y-axis label, same as in \code{\LinkA{plot}{plot}} 
\item[\code{xlab}] set the x-axis label, same as in \code{\LinkA{plot}{plot}} 
\item[\code{date.format}] re-format the dates for the xaxis; the default is "\%m/\%y" 
\item[\code{xlim}] set the x-axis limit, same as in \code{\LinkA{plot}{plot}} 
\item[\code{ylim}] set the y-axis limit, same as in \code{\LinkA{plot}{plot}} 
\item[\code{event.lines}] If not null, vertical lines will be drawn to indicate that an event happened during that time period.  \code{event.lines} should be a list of dates (e.g., \code{c("09/03","05/06"))} formatted the same as date.format.  This function matches the re-formatted row names (dates) with the events.list, so to get a match the formatting needs to be correct. 
\item[\code{event.labels}] if not null and event.lines is not null, this will apply a list of text labels (e.g., \code{c("This Event", "That Event")} to the vertical lines drawn.  See the example below. 
\item[\code{period.areas}] these are shaded areas described by start and end dates in the same format as the date.format.  This is provided as a list of pairs, e.g., \code{list(c("10/26","11/27"), c("08/29","03/33"))} See the examples below. 
\item[\code{event.color}] draws the event described in \code{event.labels} in the color specified 
\item[\code{period.color}] draws the shaded region described by \code{period.areas} in the color specified 
\item[\code{colorset}] color palette to use, set by default to rational choices 
\item[\code{pch}] symbols to use, see also \code{\LinkA{plot}{plot}} 
\item[\code{element.color}] provides the color for drawing chart elements, such as the box lines, axis lines, etc. Default is "darkgray" 
\item[\code{legend.loc}] places a legend into one of nine locations on the chart: bottomright, bottom, bottomleft, left, topleft, top, topright, right, or center. 
\item[\code{ylog}] TRUE/FALSE set the y-axis to logarithmic scale, similar to \code{\LinkA{plot}{plot}}, default FALSE 
\item[\code{date.format.in}] allows specification of other date formats in the data object, defaults to "\%Y-\%m-\%d" 
\item[\code{cex.axis}] The magnification to be used for axis annotation relative to the current setting of 'cex', same as in \code{\LinkA{plot}{plot}}.  
\item[\code{cex.legend}] The magnification to be used for sizing the legend relative to the current setting of 'cex'.  
\item[\code{cex.labels}] The magnification to be used for event line labels relative to the current setting of 'cex'.  
\item[\code{cex.lab}] The magnification to be used for x- and y-axis labels relative to the current setting of 'cex'.  
\item[\code{cex.main}] The magnification to be used for the chart title relative to the current setting of 'cex'.  
\item[\code{major.ticks}] Should major tickmarks be drawn and labeled, default 'auto'
\item[\code{minor.ticks}] Should minor tickmarks be drawn, default TRUE
\item[\code{xaxis.labels}] Allows for non-date labeling of date axes, default is NULL 
\item[\code{...}] any other passthru parameters 
\end{ldescription}
\end{Arguments}
\begin{Author}\relax
Peter Carl
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{plot}{plot}}, \code{\LinkA{par}{par}}, \code{\LinkA{axTicksByTime}{axTicksByTime}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

# These are start and end dates, formatted the same way as the default axis labels
cycles.dates = list(
    c("Oct 26","Nov 27"),
    c("Aug 29","Mar 33"),
    c("May 37","Jun 38"),
    c("Feb 45","Oct 45"),
    c("Nov 48","Oct 49"),
    c("Jul 53","May 54"),
    c("Aug 57","Apr 58"),
    c("Apr 60","Feb 61"),
    c("Dec 69","Nov 70"),
    c("Nov 73","Mar 75"),
    c("Jan 80","Jul 80"),
    c("Jul 81","Nov 82"),
    c("Jul 90","Mar 91"),
    c("Mar 01","Nov 01"))
# Event lists - FOR BEST RESULTS, KEEP THESE DATES IN ORDER
risk.dates = c(
    "Oct 87",
    "Feb 94",
    "Jul 97",
    "Aug 98",
    "Oct 98",
    "Jul 00",
    "Sep 01")
risk.labels = c(
    "Black Monday",
    "Bond Crash",
    "Asian Crisis",
    "Russian Crisis",
    "LTCM",
    "Tech Bubble",
    "Sept 11")
data(edhec)

R=edhec[,"Funds of Funds",drop=FALSE]
Return.cumulative = cumprod(1+R) - 1
chart.TimeSeries(Return.cumulative)
chart.TimeSeries(Return.cumulative, colorset = "darkblue", legend.loc = "bottomright", period.areas = cycles.dates, period.color = "lightblue", event.lines = risk.dates, event.labels = risk.labels, event.color = "red", lwd = 2)
\end{ExampleCode}
\end{Examples}

