Re: [R] Line Graph greater than 2 variables on plot
You could also try matplot(data_object[, 1], data_object[, -1], ...) ?matplot Cheers. On Thu, 21 Aug 2014 09:55:29 +1000 Duncan Mackay dulca...@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: 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 20061078.0 20.70 10.35 4 20071258.0 21.26 10.63 5 20081800.0 21.83 10.91 6 20091890.0 18.93 9.47 7 20101999.0 19.41 9.71 8 20112261.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)]),typel, 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. South Africas premier free email service - www.webmail.co.za Cotlands - Shaping tomorrows Heroes http://www.cotlands.org.za/ __ 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.
Re: [R] Line Graph greater than 2 variables on plot
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. incidencerural urban 1 2004 295.4 19.019.50 2 2005 824.1 19.959.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.939.47 7 2010 1999.0 19.41 9.71 8 2011 2261.019.899.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)]),typel, 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.
Re: [R] Line Graph - Greater than 2 variables on plot
This should do it for you: x - read.table(textConnection(A B C D + 0.65662.11851.23205 + 0.647 2.08651.232510 + 0.65322.10601.228715 + 0.64872.12901.231320 + 0.65942.12851.234125 + 0.65772.10701.234330 + 0.65792.13451.234035 + 0.67342.17051.236240 + 0.675 2.18451.237245 + 0.65922.15501.234050 + 0.66472.17101.230555), header=TRUE) matplot(x[, 4], x[, -4], type='o') On 9/20/07, Wayne Aldo Gavioli [EMAIL PROTECTED] wrote: Hello 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: A B C D 0.65662.11851.23205 0.647 2.08651.232510 0.65322.10601.228715 0.64872.12901.231320 0.65942.12851.234125 0.65772.10701.234330 0.65792.13451.234035 0.67342.17051.236240 0.675 2.18451.237245 0.65922.15501.234050 0.66472.17101.230555 Would there be a way: a) To graph all the points of data in sets A, B and C as Y coordinates on one graph, using the points in set D as the X-axis/coordinates for all 3 sets (A, B and C)? b) To be able to draw 3 lines on the graph that connect each set of data (1 line connects all the A points, one line connects all the B points, one line connects all the C points) I couldn't find anything in the examples or the help section about multiple lines on the same graph, only one line. Thanks, Wayne __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ 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.