[R] having more than one plot in one figure

kayj kjaja27 at yahoo.com
Tue Apr 20 16:34:15 CEST 2010

Hi All,

I have been trying to plot multiple line plots with different colors on one
figure. in my example below I was able to plot cat vs num1 as a dot plot
connected with lines but was not able to do that for cat vs num2 and I do
not know how to add the third plot cat vs num3. below is my code

df <- data.frame(cat=1:10, num1=rnorm(10), num2=rnorm(10), num3=rnorm(10))
plot(df$num1, type="b", col="red", xlab="categories", ylab="random numbers")
points(df$num1, type="p", pch=21, col="red",bg="red")    #plot "num1" 
points(df$num2, type="p", pch=21, col="green")   #plot "num2" 
legend(x="topright", legend=c("num1", "num2"), pch=c(16,16),
col=c("red","green"))    #add a legend 

how to make the second plot of type="b" and how to add a  third plot cat vs

I appreciate your help

View this message in context: http://n4.nabble.com/having-more-than-one-plot-in-one-figure-tp2017471p2017471.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list