# 3D array: facet wrap by the third dimension
sims = array(
cumsum(rnorm(20 * 3 * 4)), dim = c(20, 3, 4),
dimnames = list(NULL, paste("Series", 1:3), paste("Run", 1:4))
)
tinyplot(sims, type = "l")
# 4D array: facet grid by the third and fourth dimensions
sims4 = array(
rnorm(20 * 3 * 2 * 2), dim = c(20, 3, 2, 2),
dimnames = list(
time = NULL, series = paste0("s", 1:3),
model = c("A", "B"), scenario = c("low", "high")
)
)
tinyplot(sims4, type = "b", facet.args = list(prefix = TRUE))
# tile/heatmap types lay out each 2D slice as a grid
tinyplot(sims4[1:5, , , ], type = "heatmap", theme = "heatmap")
if (FALSE) { # getRversion() >= "4.5.0"
# x/y pairs: a length-2 dimension is plotted as x vs y
# (e.g., hip vs knee angle through the gait cycle, coloured by time and
# faceted by boy)
gait9 = gait[, 1:9, ] # take a subset for demonstration
tinyplot(gait9)
# all boys in a single panel instead
tinyplot(gait9, facet = FALSE)
# ... or in the background of each boy's own panel
tinyplot(
gait9,
draw = tinyplot(gait9, col = "lightgray", facet = FALSE, add = TRUE)
)
# opt out of x/y pairs, to plot the angles against time instead
tinyplot(gait9, type = "l", xy = FALSE, legend = FALSE)
}
Run the code above in your browser using DataLab