From ripley at stats.ox.ac.uk  Mon Sep  1 21:15:43 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon Sep  1 21:15:10 2003
Subject: (PR#4307) Re: [Rd] par(new=T) works differently in pdf vs
	postscript if applied before a plot statement. (PR#4037)
In-Reply-To: <200309011202.30443.andrewr@uidaho.edu>
Message-ID: <Pine.LNX.4.44.0309012004340.22766-100000@gannet.stats>

On Mon, 1 Sep 2003, Andrew Robinson wrote:

> Certainly.
> 
> postscript("test.ps")
> par(new=T)
> plot(1:10,1:10)
> dev.off()
> 
> Produces a postscript image that can be opened.  However 

But it is not a valid postscript file, and says it has 0 pages.

> pdf("test.pdf")
> par(new=T)
> plot(1:10,1:10)
> dev.off()
> 
> produces a pdf that cannot be opened by Latex or xpdf.  

Latex cannot open pdf!  (You may have meant pdftex, which uses xpdf 
internals anyway.)  Again, it's not a valid file.

Both are user error.  The issue is that your postscript viewer is being 
less careful than your pdf one.

The underlying problem is that par(new=TRUE) supresses calling NewPage on 
the device, which is not valid if there have been no pages on the device 
as yet.  That user error needs to be caught at the level of the graphics 
engine (Paul M?) and not programmed into each device, if it is to be 
caught at all.

Looks like that is possible: Rf_gpptr(dd)->state appears to record whether 
a plot has been started.

-- 
Brian D. Ripley,                  ripley@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


(PR#4307) Re: [Rd] par(new=T) works differently in pdf vs postscript if applied before a plot statement. (PR#4037)
Prof Brian Ripley