how to get the size of the plotting area in a multiplot window

Viewed 24

I am searching for a command/function to obtain the absolute width and height of a plotting area in a plotting device. Is there any? To be more exact, I would like to have the exact width and height in each of the six plotting areas, after the plotting device has been divided by par(mfrow=c(2, 3)).

1 Answers

We may use pin= parameter in par() to define the "current plot dimensions, (width, height), in inches."

Example:

png('foo.png')
op <- par(mfcol=c(2, 3), pin=c(1.2, 1.2))  ## set pars
set.seed(42)  ## for sake of reproducibility
replicate(6, plot(runif(10)))
par(op)  ## restore old pars
dev.off()

enter image description here

Related