Gundala Viswanath
2008-Jun-27 06:25 UTC
[R] Superimposing Multiple Vectors Plots in One Figure
Hi, I have 3 vectors which I want to plot as in one plot. I was wondering why this code of mine only show the last vector: __BEGIN__ library(lattice) out_fname <- paste("MyPlot.png",sep="") trellis.device("png", color=TRUE) png(out_fname) plot(vect1,type="l",col="red",xlab="Nof Genes", ylab="RMSD") plot(vect2,type="l",col="blue") plot(vect3,type="l",col="green") # final graph only showed this one. dev.off() __END__ - Gundala Viswanath Jakarta - Indonesia
Petr PIKAL
2008-Jun-27 10:09 UTC
[R] Odp: Superimposing Multiple Vectors Plots in One Figure
Hi you mix base and lattice graphics. r-help-bounces at r-project.org napsal dne 27.06.2008 08:25:55:> Hi, > > I have 3 vectors which I want to plot as in one plot. > I was wondering why this code of mine only show the last vector: > > __BEGIN__ > library(lattice) > > out_fname <- paste("MyPlot.png",sep="")why not out_fname <- "MyPlot.png" result is same> > trellis.device("png", color=TRUE)here you are setting png device for lattice output> png(out_fname)here you set png device for base graphics output> plot(vect1,type="l",col="red",xlab="Nof Genes", ylab="RMSD") > plot(vect2,type="l",col="blue") > plot(vect3,type="l",col="green") # final graph only showed this one.You make 3 plots to this device, each time overwriting previous plot.> dev.off()Here you end png device for base graphics. If you insist on not reading let say introduction to R, which is quite good for any starting point, then at least look at ?plot ?lines ?points ?par - especially mfrow, mfcol ?layout and try to test examples which are located on help pages and go through some links on those pages If you want to use Lattice then you shall go through ?xyplot and maybe some others and again test provided examples. Regards Petr> > __END__ > > - Gundala Viswanath > Jakarta - Indonesia > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.