Skip to content

Weird problem redirecting lattice graph to a file

3 messages · Jorge A. Ahumada, John Maindonald, Thomas Lumley

#
Hello,

I am having this weird issue where I cannot send a lattice graph to a device
like pdf() or png(), but this only happens when the statement is inside a
function. For example, this works:
But now, put the last three statements in a function (F(a)) and the pdf is
not produced. I tried replacing pdf with
trellis.device(device="pdf",file="test.pdf") and it still does not work.

Funny thing is that plot() or image() will work inside a function as
expected when re-directing to other devices, but not any of the lattice
functions.

Any ideas?

Thanks,

Jorge
#
Replace levelplot(a) by print(levelplot(a)) and you
should be fine.  Lattice functions return a trellis
object which has to be explicitly printed.  If you
type levelplot(a) on the command line, there is
an implicit call to print(), which has the desired
effect.

John Maindonald             email: john.maindonald at anu.edu.au
phone : +61 2 (6125)3473    fax  : +61 2(6125)5549
Centre for Mathematics & Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.
On 14 Aug 2006, at 5:54 AM, Jorge A. Ahumada wrote:

            
#
On Sun, 13 Aug 2006, Jorge A. Ahumada wrote:

            
It's a FAQ.

    7.22 Why do lattice/trellis graphics not work?


 	-thomas
Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle