[R] Creating a simple line graph

Liviu Andronic landronimirc at gmail.com
Thu Aug 27 18:46:28 CEST 2009


On 8/27/09, Josh Roll <j_r_36 at hotmail.com> wrote:
>     I am having trouble getting both graphs on the same page.  Its
> separating them, especially when i write them to a pdf.  I need visual
> comparison capabilities.  Do i need to include the two data sets in the same
> "plot" to make this happen.  Thanks

Perhaps this:
Sz= c("h1","h2","h3","h4")
 Pred=c(34790.0 ,47559.8, 21197.8, 28198.6)
 Obs=c(34740 ,48615 ,20420, 26840)
 plot(Pred, t="l", ylim=c(20000,50000))
 text(Pred, Sz, cex=0.6, pos=4, col="red")
 plot(Obs, t="l", ylim=c(20000,50000))
 text(Obs, Sz, cex=0.6, pos=4, col="blue")

Alternatively you can use lines(), but always pay attention that both
graphs be constructed with teh same x and y limits.

More information about the R-help mailing list