[R] Bug or misunderstanding of par(pin)?

Sarah Goslee sarah.goslee at gmail.com
Tue Sep 25 15:26:19 CEST 2012


Hi Vera,

You need to do it in two steps, I think because the different
parameters you're trying to set interact.

par(mfrow=c(3,4),mai=c(0.04,0.04,0.04,0.04), omi=c(0.2,0.32,0.32,2.16))
par(pin=c(1,0.87))
for(i in 1:12) plot(1:10, 1:10)

For this level of control, you probably also want to explicitly set
the dimensions of your device; see the help for whatever one you're
using for more information.

Sarah

On Tue, Sep 25, 2012 at 6:45 AM, Vera Thiemig
<vera.thiemig at jrc.ec.europa.eu> wrote:
> Dear all,
>
> I am currently trying to create a plot showing multiple single plots, for
> which the important issue is that the size of each plot region (not figure
> region!) has to be of a fixed dimension (in my case: width=1 inch, height=
> 0.87 inches).
> I tried to use "pin" to fix the plotting region to a specific size, but
> without success.
>
> The following example will visualize the problem:
>
> par(mfrow=c(3,4),pin=c(1,0.87),mai=c(0.04,0.04,0.04,0.04),
> omi=c(0.2,0.32,0.32,2.16))
>
> plot(1:10,1:10)
>
> plot(10:20,10:20)
>
> plot(20:30,20:30)
>
> plot(30:40,30:40)
>
> plot(2:11,2:11)
>
> plot(11:21,11:21)
>
> plot(21:31,21:31)
>
> plot(31:41,31:41)
>
> plot(3:12,3:12)
>
> plot(12:22,12:22)
>
> plot(22:32,22:32)
>
> plot(32:42,32:42)
>
>
>
> --> You can see that the single plots are higher than wide and not
> reflecting the size pin=c(1,0.87). The same if you set pin to c(1,1)... you
> will not get a plotting region of the size 1 * 1 inch.
>
> (Don't worry about the large white space on the right hand side or the fact
> that the labels are printed on top of another figure, this is all easily
> solvable)
>
>
>
> The question is, do I misunderstand the use of "pin" or is there a bug?
>
> And equally important, does anybody know how I could get this type of plot
> in an easy way?
>
>
>
> Thank you very much,
>
>
>
> Vera
>
>
>
>
>
> PS: in case it is not clear what I mean with "plotting region", please check
> page 6 of the following document
> http://www.stat.auckland.ac.nz/~paul/Talks/Rgraphics.pdf
>


-- 
Sarah Goslee
http://www.functionaldiversity.org




More information about the R-help mailing list