chart_xts | R Documentation |
A wrapper for function chart_Series()
from package
quantmod.
chart_xts(xtsv, colors = NULL, ylim = NULL, indic = NULL, x11 = TRUE, ...)
xtsv |
An xts time series or an OHLC time series. |
colors |
A vector of strings with the custom line colors. |
ylim |
A numeric vector with two elements containing the y-axis range. |
indic |
A Boolean vector or xts time series for specifying the shading areas, with TRUE indicating "lightgreen" shading, and FALSE indicating "antiquewhite" shading. |
x11 |
A Boolean argument: if |
... |
Additional arguments to function |
The function chart_xts()
plots a line plot of a xts
time series, or a candlestick plot if xtsv is a OHLC time
series. The function chart_xts()
plots with custom line colors and
vertical background shading, using the function chart_Series()
from
package
quantmod.
By default chart_xts()
opens and plots in an x11 window.
The function chart_xts()
extracts the chart_Series()
chart
object and modifies its ylim parameter using accessor and setter
functions. It also adds background shading specified by the indic
argument, using function add_TA()
. The indic
argument should
have the same length as the xtsv
time series. Finally the function
chart_xts()
plots the chart object and returns it invisibly.
A chart_Series()
object returned invisibly.
# Plot candlestick chart with shading
rutils::chart_xts(rutils::etfenv$VTI["2015-11"],
name="VTI in Nov 2015", ylim=c(102, 108),
indic=zoo::index(rutils::etfenv$VTI["2015-11"]) > as.Date("2015-11-18"))
# Plot two time series with custom line colors
rutils::chart_xts(na.omit(cbind(rutils::etfenv$XLU[, 4],
rutils::etfenv$XLP[, 4])), colors=c("blue", "green"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.