Achieving multiple plots with different plotting widths in R
plot, r
Solution
`layout` only works if the plots can be arranged over a regular grid, but they need not have the same widths.
layout(
matrix(
c(1,1,2,3,3,2,4,5,5,6,6,6),
nc=3, byrow = TRUE
)
)
layout.show(6)
If you want something really irregular, you can use `par(fig=...,new=TRUE)`.
plot.new()
par(mar=c(2,2,1,1))
k <- 4
f <- function()
plot(rnorm(20),rnorm(20), xlab="", ylab="", main="", las=1)
for(i in 1:k) {
par(fig=c(0,i/(k+1), (i-1)/k, i/k), new=TRUE)
f()
par(fig=c(i/(k+1),1, (i-1)/k, i/k), new=TRUE)
f()
}
Problem
I want to create multiple plots in a single plotting window in which the width of the panels of each plot are proportional to xlim of each plot. At the moment I use: ``` layout(matrix(c(1:8,10,9), 5, 2, byrow = FALSE), widths=2) layout.show(10) ``` Basically, I would like `width` to be applied individually to each plot rather than to all the plots in a column. What is the best way of doing this?