[R] Trellis graphics and clipping

Deepayan Sarkar deepayansarkar at yahoo.com
Sun Jul 29 18:34:53 CEST 2001


The problem lies (if I get you correctly) in the fact
that Lattice graphics devices need to be initialized
differently from usual R graphics devices. This has to
do with special requirements of the underlying grid
package, and also some standard parameter settings
associated with each device.

Upshot: you need to use

trellis.device(postscript, file = "filename.ps")

instead of 

postscript("filename.ps")

What this does (with regard to clipping) is that it
calls a grid function grid.start(). You can get almost

the same effect if you do

postscript(filename)
grid.start()

but trellis.device is the preferred way. The same goes
for the x11() device.

I would encourage you to read the ?Lattice help page
to familiarise yourself with this sort of
peculiarities.

Note: Currently, usual R graphics and lattice/grid
graphics don't mix, that is, you have to enclose any
calls to grid graphics functions (which includes all
lattice graphics functions) within calls to
grid.start() and grid.stop(). Hopefully, this will
change somewhat in the next release of lattice.



--- Ted.Harding at nessie.mcc.ac.uk wrote:
> Hi again folks,
> 
> I seem to have got the trellis (lattice + grid)
> business
> working basically OK, in that I can get my 5x5 array
> of
> histograms laid out as they should be.
> 
> However, there is a behaviour I can't see my way
> round.
> 
> Even when displayed in the R Graphics Window, there
> is
> some clipping (the extreme top, bottom, left and
> right
> edges are not there, so that labels, and parts of
> numerical
> scale markers all round, have been clipped off).
> 
> When I switch to the "postscript" device, with the
> comamnd
> 'postscript(filename,...)', the result is even more
> clipped,
> in that parts of the histogram plots themselves get
> cut off,
> including their titles as seen in the X11 display.
> On the
> other hand (using gv's "position meter"), it seems
> that the
> internal %%BoundingBox matches the dimensions and
> coordinates
> of what SHOULD get displayed/printed, allowing
> plenty of
> "white space" round the bit of the graphic that
> _does_ get
> displayed, so that the whole thing could have been
> fitted in
> anyway.
> 
> And if I go at it crudely, simply using
> 'dev.print()' to
> bang out a har-copy, it is even more clipped again
> ...
> 
> I've tried playing with all the obvious (to me)
> parameters
> which I can find, but it has not effect on this.
> 
> I've checked the PostScript file itself, and the
> parts that
> are missing are not mentioned therein, so it's not a
> PostScript
> "clippath" phenomenon: it's definitely R which is
> deciding not
> to output them.
> 
> What's needed is some way of coordinating the
> dimensions of
> the various levels of this process, so that the
> output to X11
> is scaled so that the whole graphic can fit in, and
> the output
> to postscript is also scaled so that it fits into
> whatever
> size of graphic is nominated (not that this should
> be an
> issue for EPS output anyway -- it would be quite
> sufficient
> to output everything and then put a BoundingBox
> round the
> lot, and never mind things like papersize and so
> forth).
> 
> So I'm bewildered. And, if anyone knows a way round
> it,
> I'd be most obliged to hear!
> 
> With thanks,
> Ted.
> 
>
--------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
> Fax-to-email: +44 (0)870 167 1972
> Date: 29-Jul-01                                     
>  Time: 13:40:47
> ------------------------------ XFMail
> ------------------------------
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help 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-help-request at stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list