par(mfg=) and postscript and pdf

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

par(mfg=) and postscript and pdf

Prof Brian Ripley
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,                  [hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: par(mfg=) and postscript and pdf

Marc Schwartz (via MN)
On Fri, 2006-01-20 at 07:47 +0000, Prof Brian Ripley wrote:

> 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).


Prof. Ripley,

Thanks for your follow up on this issue. Your efforts in resolution are
greatly appreciated.

Best regards,

Marc Schwartz

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel