# B_01_xyplot.ts

0th

Percentile

##### Time series plotting methods

This function handles time series plotting, including cut-and-stack plots. Examples are given of superposing, juxtaposing and styling different time series.

Keywords
hplot, ts
##### Usage
## S3 method for class 'ts':
xyplot(x, data = NULL,
screens = if (superpose) 1 else colnames(x),
...,
superpose = FALSE,
cut = FALSE,
type = "l",
col = if (!superpose) plot.line$col, lty = if (!superpose) plot.line$lty,
lwd = if (!superpose) plot.line$lwd, pch = if (!superpose) plot.symbol$pch,
auto.key = superpose,
par.settings = list(),
layout = NULL, as.table = TRUE,
xlab = "Time", ylab = NULL,
default.scales = list(y = list(relation =
if (missing(cut)) "free" else "same")))
##### Arguments
x
an object of class ts, which may be multi-variate, i.e. have a matrix structure with multiple columns.
data
not used, and must be left as NULL.
...
additional arguments passed to xyplot, which may pass them on to panel.xyplot.
screens
factor (or coerced to factor) whose levels specify which panel each series is to be plotted in. screens = c(1, 2, 1) would plot series 1, 2 and 3 in panels 1, 2 and 1. May also be a named list, see Details below.
superpose
overlays all series in one panel (via screens = 1) and uses grouped style settings (from trellis.par.get("superpose.line"), etc). Note that this is just a convenience argument: its only action is to change the def
cut
defines a cut-and-stack plot. cut can be a list of arguments to the function equal.count, i.e. number (number of intervals to divide into) and ov
type, col, lty, lwd, pch
graphical arguments, which are processed and eventually passed to panel.xyplot. These arguments can also be vectors or (named) lists, see Details for more information.
auto.key
a logical, or a list describing how to draw a key. See the auto.key entry in xyplot. The default here is to draw lines, not points, and any specified style arguments should show up a
par.settings
style settings beyond the standard col, lty, lwd, pch; see trellis.par.set and simpleTheme
 layout numeric vector of length 2 specifying number of columns and rows in the plot. The default is to fill columns with up to 6 rows. as.table to draw panels from top to bottom. The order is determined by the order of columns in x. xlab, ylab X axis and Y axis labels; see xyplot. Note in particular that ylab may be a character vector, in which case the labels are spaced out equally, to correspond to the panels. default.scales scales specification. The default is set to have "free" Y axis scales unless cut is given. Note, users should pass the scales argument rather than default.scales. 
 
 Details The handling of several graphical parameters is more flexible for multivariate series. These parameters can be vectors of the same length as the number of series plotted or are recycled if shorter. They can also be (partially) named list, e.g., list(A = c(1,2), c(3,4)) in which c(3, 4) is the default value and c(1, 2) the value only for series A. The screens argument can be specified in a similar way. Some examples are given below. Value An object of class "trellis". The update method can be used to update components of the object and the print method (usually called by default) will plot it on an appropriate plotting device. References Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R, Springer. ISBN: 978-0-387-75968-5 http://lmdvr.r-forge.r-project.org/ (cut-and-stack plots) See Also xyplot, panel.xyplot, plot.ts, ts, xyplot.zoo in the zoo package. Aliases xyplot.ts Examples xyplot(ts(c(1:10,10:1))) ### Figure 14.1 from Sarkar (2008) xyplot(sunspot.year, aspect = "xy", strip = FALSE, strip.left = TRUE, cut = list(number = 4, overlap = 0.05)) ### A multivariate example; first juxtaposed, then superposed xyplot(EuStockMarkets, scales = list(y = "same")) xyplot(EuStockMarkets, superpose = TRUE, aspect = "xy", lwd = 2, type = c("l","g"), ylim = c(0, max(EuStockMarkets))) ### Examples using screens (these two are identical) xyplot(EuStockMarkets, screens = c(rep("Continental", 3), "UK")) xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental")) ### Automatic group styles xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"), superpose = TRUE) xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"), superpose = TRUE, xlim = extendrange(1996:1998), par.settings = standard.theme(color = FALSE)) ### Specifying styles for series by name xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"), col = list(DAX = "red", FTSE = "blue", "black"), auto.key = TRUE) xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"), col = list(DAX = "red"), lty = list(SMI = 2), lwd = 1:2, auto.key = TRUE) ### Example with simpler data, few data points set.seed(1) z <- ts(cbind(a = 1:5, b = 11:15, c = 21:25) + rnorm(5)) xyplot(z, screens = 1) xyplot(z, screens = list(a = "primary (a)", "other (b & c)"), type = list(a = c("p", "h"), b = c("p", "s"), "o"), pch = list(a = 2, c = 3), auto.key = list(type = "o")) Documentation reproduced from package lattice, version 0.18-1, License: GPL (>= 2) Community examples Looks like there are no examples yet. Post a new example: 
 
 
 R package Rdocumentation.org Created by DataCamp.com 
 Put your R skills to the test MathJax.Hub.Config({ messageStyle: "none", jax: ["input/TeX","output/CommonHTML"], extensions: ["tex2jax.js","MathMenu.js","MathZoom.js"], TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] }, tex2jax: { inlineMath: [ ['$','$'], ['\$','\$'] ], displayMath: [ ['$$','$$'] ], processEscapes: true, preview: 'none' } }); var $jq = jQuery.noConflict(); ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//cdn.datacamp.com/sp/2.10.2.js","snowplow")); var options = { appId: 'rdocumentation', platform: 'web', post: true, discoverRootDomain: true, contexts: { webPage: true, performanceTiming: true } }; options.forceSecureTracker = true; options.postPath = '/spevent'; window.snowplow('newTracker', 'co', "www.datacamp.com", options); window.snowplow('enableActivityTracking', 10, 10); // Ping every 10 seconds after 10 seconds window.snowplow('enableLinkClickTracking'); window.snowplow('trackPageView', null, [ { schema: 'iglu:com.datacamp/user/jsonschema/1-0-0', data: { anonId:$jq.cookie('dc_aid'), } } ]); var config = { forms: { whitelist: ["snowplow_tracked"] }, fields: { blacklist: ['password', 'password_confirmation'] } }; window.snowplow('enableFormTracking', config); (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-41577880-1', 'rdocumentation.org'); ga('send', 'pageview');