[R] Odp: Superimposing Multiple Vectors Plots in One Figure

Petr PIKAL petr.pikal at precheza.cz
Fri Jun 27 12:09:27 CEST 2008


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 guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list