For a multi-plot square matrix (i.e., a multi-panel plot comprising a matrix of subplots for each combination of units, e.g., individuals), it can be useful to plot only the lower or upper triangle of the matrix to avoid visualisation of duplicate combinations. For a given square matrix, this function returns the indices of plots that lie along the lower or upper matrix.
par_tri(mf, type = "upper.tri")
mf | A vector of two numbers that specify the number of subplots in each direction in a multi-panel plot (i.e., an input to |
---|---|
type | A character vector ( |
This function returns the indices of plots along the lower or upper triangle of a multi-panel figure.
Edward Lavender
if (FALSE) { #### Example (1): Plot the upper triangle with par(mfrow = ...) pp <- par(mfrow = c(4, 4)) for(i in 1:16){ if(i %in% par_tri(mf = c(4, 4), type = "upper.tri")) plot(1) else plot.new() } par(pp) #### Example (2): Plot the lower triangle with par(mfrow = ...) pp <- par(mfrow = c(4, 4)) for(i in 1:16){ if(i %in% par_tri(mf = c(4, 4), type = "lower.tri")) plot(1) else plot.new() } par(pp) #### Example (3): Plot the upper triangle with par(mfcol = ...) pp <- par(mfcol = c(4, 4)) for(i in 1:16){ if(i %in% par_tri(mf = c(4, 4), type = "lower.tri")) plot(1) else plot.new() } par(pp) #### Example (4): Plot the lower triangle with par(mfcol = ...) pp <- par(mfcol = c(4, 4)) for(i in 1:16){ if(i %in% par_tri(mf = c(4, 4), type = "upper.tri")) plot(1) else plot.new() } par(pp) }