| sparklines | R Documentation | 
Draws a panel of vertically stacked, aligned sparklines, or time series.
sparklines(ss, times = NULL, overlap = FALSE, yscale = NULL,
           buffer = unit(0, "lines"), buffer.pars = NULL, IQR = NULL,
           ptopts = NULL, yaxis = TRUE, xaxis = "exterior",
           labeled.points = NULL, point.labels = NULL,
           label.just = c(1.2, 0.5), frame.pars = NULL,
           line.pars = gpar(lwd = 1), 
           outer.margin = unit(c(5, 4, 4, 2), "lines"), 
           outer.margin.pars = NULL, main = NULL, sub = NULL, 
           xlab = NULL, ylab = NULL, lcol = NULL, new = TRUE)
| ss | a data frame whose columns give the time series to be plotted | 
| overlap | 
 | 
| times | the times at which to plot the data; if  | 
| yscale | either a vector of length 2 giving the y-limits for all sparklines, or a list having the same length as the number of columns in  | 
| buffer | a buffer above the maximum and below the minimum values attained by the sparkline. Defaults to  | 
| buffer.pars | a list of graphics parameters describing the buffer area.  See  | 
| IQR | a list of graphics parameters to shade or otherwise delineate the interquartile range of the sparkline. Defaults to  | 
| ptopts | a list of graphics parameters describing the points on the sparkline that are plotted and labelled. In particular the first and last or minimum and maximum points are labeled if  | 
| yaxis | draws a vertical axis if  | 
| xaxis | 
 | 
| labeled.points | not implemented. See  | 
| point.labels | not implemented. See  | 
| label.just | not implemented. See  | 
| frame.pars | a list of graphics parameters describing the exact area taken up by the plotted sparkline.  See  | 
| line.pars | a list of graphics parameters describing the sparkline.  See  | 
| outer.margin | a vector of 4 units (bottom, left, top, right) giving the outer margin sizes in order (around the entire panel of sparklines). Defaults to  | 
| outer.margin.pars | a list of graphics parameters describing the outer margin.  See  | 
| main | a main title, above the stack of sparklines. | 
| sub | a character vector the length of  | 
| xlab | a string providing the label for the common x-axis or (probably a useless feature) a character vector the length of  | 
| ylab | a character vector the length of  | 
| lcol | a vector of colors the same length as the number of columns in ss to color the line. As in base graphics, can be either a vector of strings giving the color names, a numeric vector referring to the current pallette, or the output of functions like  | 
| new | defaults to  | 
In all the cases where a list of graphics parameters is needed, the valid parameter names are the same as would be valid when passed to gpar in the appropriate call. That is, passing list(fill = 'blue', col = 'red') to margin gives a margin that is blue with a red border; but adding fontface = 'bold' will have no effect, just as it would have no effect in a call to grid.rect.
We do not support non-aligned time series plots such as ts.plot(airmiles, Nile, nhtemp).
John W. Emerson, Walton Green
Tufte, E. R. (2006) Beautiful Evidence Cheshire, Connecticut: Graphics Press.
ts.plot, sparkline, sparkmat
### sparkline examples
data(beaver1)
## The default behaviour of sparklines
sparklines(beaver1)
sparklines(beaver1,
           outer.margin = unit(c(2,4,4,5), 'lines'),
           outer.margin.pars = gpar(fill = 'lightblue'),
           buffer = unit(1, "lines"),
           frame.pars = gpar(fill = 'lightyellow'),
           buffer.pars = gpar(fill = 'lightgreen'),
           yaxis = TRUE, xaxis=FALSE,
           IQR = gpar(fill = 'grey', col = 'grey'),
           main = 'Beaver 1')
data(YaleEnergy)
y <- YaleEnergy[YaleEnergy$name==YaleEnergy$name[2],]
sparklines(y[,c("ELSQFT", "STEAM")], times=y$year+y$month/12,
           main="Branford Electric and Steam Consumption")
## Adding a pair of sparklines to an existing plot
grid.newpage()
pushViewport(viewport(w = 0.8, h = 0.8))
sparklines(data.frame(x = rnorm(10), y = rnorm(10, mean=5)), new = FALSE)
popViewport()
grid.newpage()
pushViewport(viewport(w = 0.8, h = 0.8))
sparklines(data.frame(x = rnorm(10), y = rnorm(10, mean=2)),
                buffer = unit(1, "lines"),
                frame.pars = gpar(fill = 'lightyellow'),
                yaxis = TRUE, xaxis=FALSE,
                IQR = gpar(fill = 'grey', col = 'grey'), new = FALSE)
popViewport()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.