get.grid | R Documentation |
This function outputs a matrix to be used with the layout function according to a desired number of plots and to the proportionality between width and height of the plot region
get.grid(x, prop = 0.5)
x |
The desired number of plots. |
prop |
A numeric value between 0 and 1. A proportionality factor for distributing plot more or less along plot area width (low value) or height (high value). By default to 0.5, a balanced distribution. |
# If wanting to do six plots
layout.matrix<-get.grid(6)
layout(layout.matrix)
for(i in 1:6){
plot(1:10,1:10,pch=21,col=NA,bg=ULT::contrasting.palette()[i])
}
# If wanting to do four plots that are all very tall
layout.matrix<-get.grid(4,prop=0)
layout(layout.matrix)
for(i in 1:4){
boxplot(rnorm(100,i,1))
}
# If wanting to do four plots that are all very wide
layout.matrix<-get.grid(4,prop=1)
layout(layout.matrix)
for(i in 1:4){
plot(density(rnorm(100,i,1)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.