| bestRowColumnSetting | R Documentation |
Number of rows and columns in an optimal plot grid for n plots
bestRowColumnSetting(n, target.ratio = 1, device.ratio = NULL)
n |
number of plots to be placed in a matrix of equally sized plot cells |
target.ratio |
desired height/width ratio within each plot (ignoring margins). Default: 1 |
device.ratio |
desired height/width ratio in the output device. Default:
|
named vector of two elements with the first element (nrow)
representing the number of rows and the second element (ncol)
representing the number of columns for an optimal plot grid to be used for
n plots in the current plot region
# save current graphical parameter setting
old.par <- graphics::par(no.readonly = TRUE)
for (i in 2:5) {
graphics::par(mfrow = kwb.plot::bestRowColumnSetting(i))
for (j in 1:i) {
plot(seq_len(j), main = paste0("j = ", j, "/", i))
}
}
# restore graphical parameter setting
graphics::par(old.par)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.