[R] multiple plots

Pete Brecknock Peter.Brecknock at bp.com
Sat Mar 8 22:33:07 CET 2014


slavia wrote
> Hi,
> 
> I have some values that I need to represente in the same plot.
> For exemple, if I have, 
> 
> c<-c(200,205,210,215,220,225,230,235)
> a<-c(0.032,0.44,0.86,0.65,0.53,0.213,0.46,0.231)
> b<-c(0.325,0.657,0.784,0.236,0.798,0.287,0,748,0.785)
> d<-c(0.786,0.217,0.538,0.513,0.870,0.326,0.647,0.217)
> 
> c is a independente variable (represented in x axis) and a, b, d are
> diferente dependente varible (represented in a y axes). a, b and d should
> be diferent lines, How can I do that?
> 
> Thank you


Think there was a typo in the vector b where 0,748 should have been 0.748.

To overlay lines on the same plot you could try the lines function.

# Corrected Data
c<-c(200,205,210,215,220,225,230,235) 
a<-c(0.032,0.44,0.86,0.65,0.53,0.213,0.46,0.231) 
b<-c(0.325,0.657,0.784,0.236,0.798,0.287,0.748,0.785) 
d<-c(0.786,0.217,0.538,0.513,0.870,0.326,0.647,0.217) 

# Plot
plot(c,a, type="o", col="red", ylim=c(min(a,b,d),max(a,b,d)))
lines(c,b, type="o",col="blue")
lines(c,d, type="o",col="green")

HTH

Pete



--
View this message in context: http://r.789695.n4.nabble.com/multiple-plots-tp4686489p4686501.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list