[R] Concat Multiple Plots into one PNG figure

From: Gundala Viswanath <gundalav_at_gmail.com>
Date: Tue, 10 Jun 2008 23:26:51 +0800

Dear experts,

I tried to put the two plots into one final PNG figure with the following script.

However instead of giving 2 plots in one figure, it only gives the the last plot in one figure.

What's wrong with my script below?

__BEGIN__

in_fname <- paste("mydata.txt.",sep="")
out_fname <- paste("finalplot.png",sep="")

dat <- read.table(in_fname, comment.char = "!" , na.strings = "null"); dat.pca <- prcomp(dat[,1:ncol(dat)], retx=TRUE, scores=TRUE)

trellis.device("png", color=TRUE)
png(out_fname)

# End figure expected to be 1 row 2 columns par(mfrow = c(1,2))

# Two plots which I want to put into one PNG figure xyplot(dat.pca$x[,1] ~ dat.pca$x[,2], xlab="First Component", ylab="Second Component")
xyplot(dat.pca$x[,2] ~ dat.pca$x[,3], xlab="Second Component", ylab="Third Component")

dev.off()

__END__

-- 
Gundala Viswanath



-- 
Gundala Viswanath


______________________________________________
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 Tue 10 Jun 2008 - 17:38:50 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 Tue 10 Jun 2008 - 18:30:40 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