[R] postscript bounding box in trellis/lattice plot is wrong ?

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Mar 2 01:26:49 CET 2006


On 3/1/06, context grey <mobygeek at yahoo.com> wrote:
> Hi,  a problem involving postscript bounding boxes:
>
> I'm composing three scatterplots into a single figure,
> postsript for publication.
>
> The individual scatterplots should be square, so
> the overall figure should have a roughly 1:3 sort of
> aspect ratio.
>
> By default however, the overall figure comes out
> nearly square,
> and the scatterplots are stretched vertically.
>
> I fixed this by adding "aspect=1/1" to the individual
> xyplot()
> calls.  This produces a figure that looks correct.
>
> However, the bounding box for the figure leaves way
> too much
> space above and below... as if it is still assuming
> that the
> figure is square rather than 1:3 in proportions.
>
>
> Is there any fix for this?   Thanks for any advice
>
> Here's the approximate code (very simple):
> ------------------------------------
>
> library(lattice)
>
>     plt_hi[[1]] <- xyplot(thedat[,ir] ~ thedat[,ic],
> aspect=1/1)
> ...
>     plt_hi[[2]] <- xyplot(thedat[,ir] ~ thedat[,ic],
> aspect=1/1)
> ...
>     plt_hi[[2]] <- xyplot(thedat[,ir] ~ thedat[,ic],
> aspect=1/1)
>
> trellis.device(postscript, file=thefile, color=F)

For starters, you should heed the advice in ?postscript:

     The postscript produced for a single R plot is EPS (_Encapsulated
     PostScript_) compatible, and can be included into other documents,
     e.g., into LaTeX, using '\includegraphics{<filename>}'.  For use
     in this way you will probably want to set 'horizontal = FALSE,
     onefile = FALSE, paper = "special"'.

> print(plt_hi[[1]], split=c(1,1,3,1), more=T)
> print(plt_hi[[2]], split=c(2,1,3,1), more=T)
> print(plt_hi[[3]], split=c(3,1,3,1), more=F)
> dev.off()


Deepayan
--
http://www.stat.wisc.edu/~deepayan/




More information about the R-help mailing list