[Rd] Re: [R] problem clipping R postscript plots within latex (PR#625)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Wed, 2 Aug 2000 22:39:38 +0200 (MET DST)


On Wed, 2 Aug 2000 p.dalgaard@biostat.ku.dk wrote:

> Martin Maechler <maechler@stat.math.ethz.ch> writes:
> 
> > (from R-help)
> >     PD> Stephen Eglen <stephen@cogsci.ed.ac.uk> writes:
> > 
> >     >  > > generated by R into a latex document.  Specifically, the latex package
> >     >  > > graphicsx allow you to specify the bounding box of the postscript
> >     >  > > file, so that you can just show _part_ of the postscript file if you
> >     >  > > tell it to also clip the area outside of the bounding box.
> >     > ...
> >     >  > Ow. This stems from the use of "initclip" in the R-generated PS. One
> >     >  > shouldn't do that, one should bracket clipped graphics within
> >     >  > gsave/grestore instead. Sounds a bit tricky to get right.
> >     > 
> >     > Thanks.  To solve my current problem, I changed the definition of the
> >     > `cl' operator in the postscript file to:
> >     > 
> >     > /cl  { gsave initclip newpath 3 index 3 index moveto 1 index
> >     >        4 -1 roll lineto  exch 1 index lineto lineto
> >     >        closepath clip grestore newpath } def
> >     > 
> >     > [i.e. just adding the gsave ... grestore pair]
> >     > 
> >     > Whether this is the proper solution though is another matter...
> > 
> >     PD> It isn't. It grestore-s before actually plotting the stuff that
> >     PD> needs to be clipped, so effectively you just disabled R's
> >     PD> clipping. A better way would be to start the plotting with a "gs"
> >     PD> and have
> > 
> >     /cl  { gr gs newpath 3 index 3 index moveto 1 index
> > 	   4 -1 roll lineto  exch 1 index lineto lineto
> > 	   closepath clip newpath } def
> > 
> >     PD> and end everything with a "gr". Not too sure that is perfectly
> >     PD> safe, though...
> > 
> > Are you working on this, Peter?
> > Otherwise, "R-bugs" should probably get about the above report..
> 
> Done... 

Just to note that ?postscript says

    The postscript produced by R is EPS (Encapsulated PostScript)
    compatible,

yet initclip is not allowed in EPS files (PostScript Language Reference
Manual, 2nd edition).  I think the statement was possibly true once ....

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._