Hi

Try something like (as you have not given a reproducible example)

library(lattice)

xyplot(y1 + y2+ y3 ... ~ x, data = your data.frame, type = "b",
allow.multiple = TRUE)

Read ?xyplot CAREFULLY as there are many possibilities

you may want to have a look at 

library(lattice)
?useOuterStrips

and other functions in the package

See 

http://lmdvr.r-forge.r-project.org/figures/figures.html

for ideas

Regards

Duncan 

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au

-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Waseq Ziaie
Sent: Thursday, 21 August 2014 08:55
To: r-help@r-project.org
Subject: [R] Line Graph greater than 2 variables on plot

Hi all,

I was wondering if anyone knew how to construct a multiple line graph on R,
where there  are 2 (or more) sets of data points plotted against some x axis
of
data, and you can draw a line on the graph connecting each set of data
points.
for example:
  time..years.          incidence        rural   urban
1         2004          295.4           19.01    9.50
2         2005          824.1           19.95    9.98
3         2006          1078.0           20.70  10.35
4         2007          1258.0                   21.26  10.63
5         2008          1800.0           21.83   10.91
6         2009                   1890.0          18.93    9.47
7         2010                   1999.0                   19.41   9.71
8         2011             2261.0        19.89    9.95
9         2012             2321.0                  20.28          10.14

Idea:
a) I am planning plot a graph of data illustrated above where on Y-axis we
can have data in sets INCIDENCE, RURAL and URBAN and on X-axis the points in
set TIME..YEARS.
b) Would like to be able to draw three lines ,connecting the points for each
set of INCIDENCE, RURAL and URBAN over TIME..YEARS.

I have tried really hard to find something but wasn't successful, the latest
information I received after doing the command shown underneath was:

> plot(data1$time..years.,data1$incidence,main="Plot illustrating diarrhoeal
incidence over time", xlab="Time(years)",ylab="Diarrhoeal
incidence",ylim=range(data[c("incidence","rural","urban")]),type"l", col=2)
Error: unexpected string constant in
"plot(data1$time..years.,data1$incidence,main="Plot illustrating diarrhoeal
incidence over time", xlab="Time(years)",ylab="Diarrhoeal
incidence",ylim=range(data[c("incidence","rural","urban")])"

Many thanks,
W
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to