[Rd] par(mfg=) and postscript and pdf

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jan 20 08:47:36 CET 2006


This is related to the incorrect bug report PR#7820.  Marc Schwartz
pointed out in

https://stat.ethz.ch/pipermail/r-devel/2005-April/033016.html

an example of a real problem.  If you call par(mfg=) after par(mfrow) (or 
mfcol) and before you have done any plotting, NewPage is not called on the 
device at the start of the first page.  That causes the DSC comments to be 
incorrect on postscript() and much worse on pdf().

You would get the same effect by calling par(new=T) before plot.new() is 
called, except that is disallowed.  par(mfg=) does set new=T internally, 
and also sets the plot number to a valid one, both of which inhibit 
calling NewPage.  I've managed to overcome this by ensuring that
GNewPage always calls NewPage on an unused device (there is an internal 
'state' variable which records the latter).

This is safe in the sense that the worst it could do is to produce an 
unwanted new page.  I can't see how this could happen but the design of 
the internals of base graphics is very complicated and undocumented, so I 
am only putting the change in R-devel (along with fixes to the 
long-standing graphics bugs PR#1235 and PR#2630).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list