I'd like to plot data that's in the form of a table such as this: 1 2 4 6 8 12 a 10 11 12 14 15 30 b 2 3 3 4 5 5 c 1 1 2 2 3 3 Where the row headers are the results for different series of tests, and the column headers are the x-values. I'd like to plot this as a set of lines, one each for "a", "b", and "c". I can rearrange the data as needed, but I'm wondering if there's an easy way to do this in R. I suppose I could just use gnuplot for this plot if it'll be simpler, but I'd like to avoid changing the visual style of the graphs just for this set. Thanks, -- Rahul Jain rjain2 at lucent.com 908-559-6024 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 8 Aug 2001, Jain, Rahul (Rahul) wrote:> I'd like to plot data that's in the form of a table such as this: > > 1 2 4 6 8 12 > a 10 11 12 14 15 30 > b 2 3 3 4 5 5 > c 1 1 2 2 3 3 > > Where the row headers are the results for different series of tests, and the > column headers are the x-values. > > I'd like to plot this as a set of lines, one each for "a", "b", and "c". I > can rearrange the data as needed, but I'm wondering if there's an easy way > to do this in R. I suppose I could just use gnuplot for this plot if it'll > be simpler, but I'd like to avoid changing the visual style of the graphs > just for this set.matplot(t(table), type="l") or something similar: you get the idea which is to use matplot to plot columns. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Jain, Rahul (Rahul)" <rjain2 at lucent.com> writes:> I'd like to plot data that's in the form of a table such as this: > > 1 2 4 6 8 12 > a 10 11 12 14 15 30 > b 2 3 3 4 5 5 > c 1 1 2 2 3 3 > > Where the row headers are the results for different series of tests, and the > column headers are the x-values. > > I'd like to plot this as a set of lines, one each for "a", "b", and "c". I > can rearrange the data as needed, but I'm wondering if there's an easy way > to do this in R. I suppose I could just use gnuplot for this plot if it'll > be simpler, but I'd like to avoid changing the visual style of the graphs > just for this set.Here's one way: matplot(colnames(m),t(m),type="b") -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
You can use the matplot function on the transpose of your table (without header): matplot(t(table),type="l"). If you give the x-values (top row of your table) as the first argument, they'll label the x-axis: matplot(x,t(table),type="l"). Lots of control over colors, styles, etc is available: see help(matplot). ts.plot from the time series library also works. Reid Huntsinger -----Original Message----- From: Jain, Rahul (Rahul) [mailto:rjain2 at lucent.com] Sent: Wednesday, August 08, 2001 3:38 PM To: 'r-help at lists.r-project.org' Subject: [R] Plotting multiple series of data I'd like to plot data that's in the form of a table such as this: 1 2 4 6 8 12 a 10 11 12 14 15 30 b 2 3 3 4 5 5 c 1 1 2 2 3 3 Where the row headers are the results for different series of tests, and the column headers are the x-values. I'd like to plot this as a set of lines, one each for "a", "b", and "c". I can rearrange the data as needed, but I'm wondering if there's an easy way to do this in R. I suppose I could just use gnuplot for this plot if it'll be simpler, but I'd like to avoid changing the visual style of the graphs just for this set. Thanks, -- Rahul Jain rjain2 at lucent.com 908-559-6024 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Thanks for the help, everyone. matplot was exactly what I needed. -- Rahul Jain rjain2 at lucent.com 908-559-6024> -----Original Message----- > From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] > Sent: Wednesday, August 08, 2001 4:15 PM > To: Jain, Rahul (Rahul) > Cc: 'r-help at lists.r-project.org' > Subject: Re: [R] Plotting multiple series of data > > > On Wed, 8 Aug 2001, Jain, Rahul (Rahul) wrote: > > > I'd like to plot data that's in the form of a table such as this: > > > > 1 2 4 6 8 12 > > a 10 11 12 14 15 30 > > b 2 3 3 4 5 5 > > c 1 1 2 2 3 3 > > > > Where the row headers are the results for different series > of tests, and the > > column headers are the x-values. > > > > I'd like to plot this as a set of lines, one each for "a", > "b", and "c". I > > can rearrange the data as needed, but I'm wondering if > there's an easy way > > to do this in R. I suppose I could just use gnuplot for > this plot if it'll > > be simpler, but I'd like to avoid changing the visual style > of the graphs > > just for this set. > > matplot(t(table), type="l") > > or something similar: you get the idea which is to use matplot to plot > columns. > > > -- > Brian D. Ripley, ripley at stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272860 (secr) > Oxford OX1 3TG, UK Fax: +44 1865 272595 >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._