Weird problem redirecting lattice graph to a file
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:
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:
a <- matrix(0,5,5)
pdf("test.pdf")
levelplot(a)
dev.off()
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 -- Jorge A. Ahumada, Ph.D. Technical Director, TEAM Center for Applied Biodiversity Science Conservation International 1919 M Street, NW Suite 600 Washington, DC 20036-3521 Ph: 202-912-1516 j.ahumada at conservation.org http://www.teaminitiative.org/
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac