Reaching multiple graphs with different graph widths in R

I want to create several charts in one chart window, in which the width of the panels of each chart is proportional to xlim of each chart.

I am currently using:

layout(matrix(c(1:8,10,9), 5, 2, byrow = FALSE), widths=2) layout.show(10) 

Basically, I would like width applied individually to each plot, and not to all the graphs in the column. What is the best way to do this?

+4
source share
1 answer

layout works only if the graphics can be arranged on a regular grid, but they should not have the same width.

 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() } 
+4
source

Source: https://habr.com/ru/post/1415664/


All Articles