[R] two plots on the same axis

Jim Lemon jim at bitwrit.com.au
Wed Oct 7 12:53:34 CEST 2009


On 10/07/2009 07:12 PM, ogbos okike wrote:
> Good morning. I wish to plot two data on the same axis. I tried plot(x,y,
> type = "l") for the first and tried to use lines or points(x,y, lty = 2, col
> = 4) to add or plot the second data on alongside the first. However, what I
> got was not encouraging.
> I have attached the two data and would be pleased if anybody could be of
> help.
Hi Ogbos,
Try this:

plot(oo1$daymon,oo1[,4],
  main="Two years of something",type="l",col="blue",
  ylim=c(3300,4400))
  lines(oo2$daymon,oo2[,4],col="red")
legend(oo1$daymon[100],3600,c("2005","2006"),
  col=c(4,2),lty=1)

Jim




More information about the R-help mailing list