[R] Multiple line plots

Don MacQueen macq at llnl.gov
Wed Jun 15 22:11:04 CEST 2005


Here is an example. It assumes the data is in a 
data frame, with all variables numeric.

  tst <- data.frame(yr=1981:1990,y1=rnorm(10), y2=5+rnorm(10), y3=rnorm(10)-3)
  plot(tst$yr, tst$y1, ylim=range(tst[,-1]),type='l')
  lines(tst$yr,tst$y2,col=2)
  lines(tst$yr,tst$y3,col=3)

-Don

At 1:50 PM -0500 6/15/05, Mihai Nica wrote:
>Content-Type: text/plain; format=flowed
>X-MIME-Autoconverted: from 8bit to 
>quoted-printable by smtp-4.llnl.gov id 
>j5FIxVe7010769
>
>Greetings,
>
>I would like to plot three lines on the same 
>figure, and I am lost. There is an answer to a 
>similar thread
 but I tried matplot and it is 
>beyond me. An example of the data follows:
>
>Year	EM	IM	BM
>1983	9.1	16.8	-7.7
>1984	12.0	18.0	-6.0
>1985	13.6	19.1	-5.5
>1986	12.4	17.3	-4.9
>1987	14.6	20.3	-5.7
>1988	20.6	23.3	-2.6
>1989	25.0	27.2	-2.2
>1990	28.4	30.2	-1.8
>1991	33.3	31.2	2.1
>1992	40.6	35.2	5.4
>1993	41.6	39.9	1.7
>1994	50.8	49.5	1.3
>1995	46.3	61.7	-15.4
>1996	56.8	73.0	-16.2
>1997	71.4	85.9	-14.5
>1998	79.0	94.7	-15.7
>1999	87.0	109.7	-22.7
>2000	111.7	135.9	-24.2
>2001	101.5	131.4	-29.9
>2002	97.5	134.6	-37.1
>2003	97.4	138.1	-40.6
>2004	110.8	155.8	-45.1
>
>Thanks,
>
>Mihai
>
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA




More information about the R-help mailing list