Description Usage Arguments Details Value See Also Examples
Adds lines and (optionally) axes positioned relative to reference coordinates and scaled to the size of a character
1 2 3 4 |
x, y |
numeric vector of values for sparklines |
x_pt, y_pt |
numeric length 1 indicating coordinate to use as a reference for positioning sparkline |
y_align |
character indicating the portion of |
x_align |
same as |
scale_xy |
Logical; if TRUE (default) |
x_cex, y_cex |
numeric, scaling factor to adjust the size of the sparklines in either direction; does nothing if |
ax_sides |
Integer value(s) in 1:4 indicating the sides of the sparkline to be bordered by a solid 'axis' line; if |
col |
color of the sparkline |
lwd |
width of the sparkline |
acol |
color of the axis lines |
awd |
width of the axis lines |
Created as a way of associating a mini time series with a particular point in a primary time series. For example, if plotting monthly averages, could add a sparkline for each month showing daily values.
Returns NULL invisibly
For another approach to adding miniaturized time series data to a specific location on a figure, see polarGlyph
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # fake data
x <- 1:20
y <- cumsum(rnorm(20))
# plot squared values
# to show that sparkline x-y
# can be on a different scale
plot(x^2, y^2, type='l')
# add sparklines
# showing a mini version of the time series
# leading into and out of each point
# of the big time series
for(i in 1:length(x)){
xpt <- x[i]^2
ypt <- y[i]^2
sparklines(
x, y, xpt, ypt,
y_align="right", x_align="right", ax_sides=c(1,2), col="red", awd=0.5
)
sparklines(
x, y, xpt, ypt,
y_align="left", x_align="left", ax_sides=c(1,4), col="blue", awd=0.5
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.