[R] Saving lattice plot as a PDF
Deepayan Sarkar
deepayan.sarkar at gmail.com
Mon Dec 10 00:46:15 CET 2007
On 12/9/07, Judith Flores <juryef at yahoo.com> wrote:
> Hi there,
>
> I need to save a series of lattice plots as a PDF,
> this is my code so far:
>
> windows(height=8,width=6)
> plot.new()
> library('grid')
> lattice.options(layout.heights=list(top.padding=list(x=0.15,
> units="inches")))
> print(plot1, split=c(1,1,2,3), more=TRUE)
> print(plot2, split=c(1,2,2,3), more=TRUE)
> print(plot3, split=c(1,3,2,3), more=TRUE)
> print(plot4, split=c(2,1,2,3), more=TRUE)
> print(plot5, split=c(2,2,2,3), more=TRUE)
> print(plot6, split=c(2,3,2,3), more=FALSE)
>
> ltext(grid.locator(), label='text', cex=1.3)
> ltext(grid.locator(), label='text', cex=1.3)
>
> And when I open the PDF created I see "text" at the
> bottom of may layout, even though I placed it at the
> top of the sheet.. If I save it as a metafile of PNG
> the layoout is correct.
I suspect the ``native'' coordinate system (which is all ltext() will
know about) is different for PDF. The following might work as
alternative for the ltext calls.
grid.text(label = "text",
cex = 1.3,
vp = do.call(viewport, grid.locator(unit="npc")))
-Deepayan
More information about the R-help
mailing list