[R] Problem saving xYplot graph to file

Kevin E. Thorpe kevin.thorpe at utoronto.ca
Fri Apr 13 15:22:37 CEST 2007


Hello.

I am having a problem directing the results of xYplot in the Hmisc
package to a file.  First I'll give you my sessionInfo and then my
data and code, afterwhich I'll describe my problem.

> sessionInfo()
R version 2.4.1 Patched (2007-02-26 r40806)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] "grid"      "stats"     "graphics"  "grDevices" "utils"     "datasets"
[7] "methods"   "base"

other attached packages:
  lattice     Hmisc   acepack
"0.14-16"   "3.3-1" "1.3-2.2"

`pcs.means.sd` <-
structure(list(group = structure(as.integer(c(1, 2, 1, 2, 1,
2, 1, 2)), .Label = c("Strength", "Aerobic"), class = "factor"),
    vis = c(0, 0, 2, 2, 6, 6, 18, 18), pcs = c(39.0334828308696,
    36.9953199347826, 41.8490848139535, 39.0470522655814, 44.9146868080952,
    41.04989196775, 46.4435591345946, 39.928985488), sd = c(8.6865669448865,
    8.133546159086, 8.73403314236636, 8.34564558942182, 9.95941054193798,
    10.7706814575657, 8.88934684511587, 10.9269199038043)), .Names =
c("group",
"vis", "pcs", "sd"), row.names = c("1", "2", "3", "4", "5", "6",
"7", "8"), class = "data.frame")

Ylim <- c(pcs.means.sd$pcs-pcs.means.sd$sd-1,
	pcs.means.sd$pcs+pcs.means.sd$sd+1)
trellis.device("postscript",color=FALSE,file="pcs.ps")
xYplot(Cbind(pcs,pcs-sd,pcs+sd)~vis,data=pcs.means.sd,groups=group,type='b',
	method="bands",scales=list(x=list(at=c(0,2,6,18))),
	ylim=Ylim,xlab="Months",ylab="PCS")
dev.off()

Now, when I call xYplot without the trellis.device() and dev.off() the
graph I want displays on the screen.  When I try this with the
trellis.device() the plot is only partially created.  The axes are drawn
but the actual plot area is empty except for the "curve" labels,
although these are plotted on to of each other in the wrong place.

I also tried putting my xYplot() inside a print() which gave the same
results.

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: kevin.thorpe at utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057



More information about the R-help mailing list