[R] unexpected par('pin') behaviour

joerg van den hoff j.van_den_hoff at fz-rossendorf.de
Wed Jul 13 16:00:58 CEST 2005


hi everybody,

I noticed the following: in one of my scripts 'layout' is used to 
generate a (approx. square) grid of variable dimensions (depending on 
no. of input files). if the no. of subplots (grid cells) becomes 
moderately large  (say > 9) I use a construct like

   ###layout grid computation and set up occurs here###
    ...
   opar <- par(no.readonly = T);
   on.exit(par(opar))
   par(mar=c(4.1, 4.1, 1.1, .1))
   ###plotting occurs here####
    ...

to reduce the figure margins to achieve a more compact display. apart 
from 'mar' no other par() setting is modified.

this works fine until the total number of subplots becomes too large 
("large" depending on the current size of the X11() graphics device 
window, e.g. 7 x 6 subplots for the default size fo x11()).

I then get the error message (only _after_ all plots are correctly 
displayed, i.e. obviously during execution of the above on.exit() call)

Error in par(opar) :
invalid value specified for graphics parameter "pin"


and par("pin") yields:

[1]  0.34864 -0.21419


which indeed is invalid (negative 2nd component).

I'm aware of this note from ?par:

    The effect of restoring all the (settable) graphics parameters as
      in the examples is hard to predict if the device has been resized.
      Several of them are attempting to set the same things in different
      ways, and those last in the alphabet will win.  In particular, the
      settings of 'mai', 'mar', 'pin', 'plt' and 'pty' interact, as do
      the outer margin settings, the figure layout and figure region
      size.


but my problem occurs without any resizing of the x11() window prior to 
resetting par to par(opar).

any ideas, what is going on?

platform powerpc-apple-darwin7.9.0
arch     powerpc
os       darwin7.9.0
system   powerpc, darwin7.9.0
status   Patched
major    2
minor    1.0
year     2005
month    05
day      12
language R

regards,

joerg




More information about the R-help mailing list