[R] Line Graph greater than 2 variables on plot
David McPearson
dmcp at webmail.co.za
Thu Aug 21 13:26:21 CEST 2014
You could also try matplot(data_object[, 1], data_object[, -1], ...)
?matplot
Cheers.
On Thu, 21 Aug 2014 09:55:29 +1000 "Duncan Mackay" <dulcalma at bigpond.com>
wrote
> 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: mackay at northnet.com.au
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of Waseq Ziaie
> Sent: Thursday, 21 August 2014 08:55
> To: r-help at 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 at 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 at 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.
____________________________________________________________
South Africas premier free email service - www.webmail.co.za
Cotlands - Shaping tomorrows Heroes http://www.cotlands.org.za/
More information about the R-help
mailing list