[R] pdf function, resize xyplot plot automatically

From: Afshartous, David <DAfshartous_at_med.miami.edu>
Date: Wed, 02 Jun 2010 14:34:03 -0400

All,

When saving plots to a pdf file via the pdf function, I would like to be able to automatically expand the graphics device to achieve the same result as when one does this manually (e.g., clicking the green expand button on the upper left of the graph on Mac OS). Consider simple example below:

library("lattice")
foo.frm = data.frame(Subject = rep(c(1:4), each = 9), Y = rnorm(36), Time = rep(c( 0, 15, 30, 45, 60, 90, 150, 210, 270), 4)) xyplot(Y ~ Time | as.factor(Subject), data = foo.frm, scale = list(x = list(at = c(0, 15, 30, 45, 60, 90, 150, 210, 270))))

The tick marks are very close but this is resolved by expanding the graphics device as mentioned above. However, in the code below the file that is created by the pdf function is created w/o such an adjustment. I suppose one could work around this via changing the number of tick marks, but if there was a way to automatically achieve the expansion of the graph as when done manually that would be great. Any tips much appreciated.

pdf(file = "foo.pdf", onefile = T)
xyplot(Y ~ Time | as.factor(Subject), data = foo.frm, scale = list(x = list(at = c(0, 15, 30, 45, 60, 90, 150, 210, 270)))) dev.off()

Thanks,
David



David Afshartous, Ph.D.
Research Assistant Professor
University of Miami, Miller School of Medicine Division of Clinical Pharmacology
1500 N.W. 12th Avenue, 15th Floor West
Miami, Florida 33136

E-mail: afshar_at_med.miami.edu
Phone: +1 305-243-1549



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jun 2010 - 20:07:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Jun 2010 - 10:40:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive