Hello ! There is something quite simple I want to do with R but I found nowhere in the help how to do it. I just want to plot data which are in a matrix, every column being a data set and having the same x-axis (just an index). So for example if I have a 50 x 6 matrix I want 6 set of points on the same plot. I tried plot,new() plot(MATRIX[,1]) plot(MATRIX[,2]) ... but it replaces the previous plot each time. Thank you very much if you can help !
On 9/7/2005 9:28 AM, St??phane Mattei wrote:> Hello ! > > > There is something quite simple I want to do with R but I found nowhere in the help how to do it. > I just want to plot data which are in a matrix, every column being a data set and having the same > x-axis (just an index). > > So for example if I have a 50 x 6 matrix I want 6 set of points on the same plot. > > I tried > plot,new() > plot(MATRIX[,1]) > plot(MATRIX[,2]) > ... > > but it replaces the previous plot each time.See ?matplot. For example, matplot(1:10, cbind(rnorm(10),rnorm(10)), type='l')
Have a look at ?matplot St??phane Mattei wrote:> Hello ! > > > There is something quite simple I want to do with R but I found nowhere in the help how to do it. > I just want to plot data which are in a matrix, every column being a data set and having the same > x-axis (just an index). > > So for example if I have a 50 x 6 matrix I want 6 set of points on the same plot. > > I tried > plot,new() > plot(MATRIX[,1]) > plot(MATRIX[,2]) > ... > > but it replaces the previous plot each time. > > > Thank you very much if you can help ! > > ______________________________________________ > 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 >-- --------------------------------------------- Henrik Andersson Netherlands Institute of Ecology - Centre for Estuarine and Marine Ecology P.O. Box 140 4400 AC Yerseke Phone: +31 113 577473 h.andersson at nioo.knaw.nl http://www.nioo.knaw.nl/ppages/handersson
Le 07.09.2005 15:28, St??phane Mattei a ??crit :>Hello ! > > >There is something quite simple I want to do with R but I found nowhere in the help how to do it. >I just want to plot data which are in a matrix, every column being a data set and having the same >x-axis (just an index). > >So for example if I have a 50 x 6 matrix I want 6 set of points on the same plot. > >I tried >plot,new() >plot(MATRIX[,1]) >plot(MATRIX[,2]) >... > >but it replaces the previous plot each time. > >Hello Stephane, there is a lot of solutions for your problem. It's up to you : ?matplot ?points ?lines par(new=TRUE) http://addictedtor.free.fr/graphiques/search.php?q=parallel Good day. Romain -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~ Romain FRANCOIS - http://addictedtor.free.fr ~~~~~~ ~~~~ Etudiant ISUP - CS3 - Industrie et Services ~~~~ ~~ http://www.isup.cicrp.jussieu.fr/ ~~ ~~~~ Stagiaire INRIA Futurs - Equipe SELECT ~~~~ ~~~~~~ http://www.inria.fr/recherche/equipes/select.fr.html ~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
Thank you all for your answers. I eventually use the points command plot(MATRIX[,1]) points(MATRIX[,2]) points(MATRIX[,3]) ... with matplot I had numbers instead of points with type="p" and par(new=TRUE) makes complications with the axis.
On 9/7/05, St??phane Mattei <stephane.mattei at epfl.ch> wrote:> Hello ! > > > There is something quite simple I want to do with R but I found nowhere in the help how to do it. > I just want to plot data which are in a matrix, every column being a data set and having the same > x-axis (just an index). > > So for example if I have a 50 x 6 matrix I want 6 set of points on the same plot. > > I tried > plot,new() > plot(MATRIX[,1]) > plot(MATRIX[,2]) > ... > > but it replaces the previous plot each time.Others have already mentioned matplot, lines and points but just to add to the list, if your problem is a time series then you could also use plot.zoo: library(zoo) z <- zoo(MATRIX, x) plot(z, plot.type ="single") # one plot plot(z) # separate plots
I found a lot of answers at this type of problem website wrt graphics and multiple plots- I bet the book will be useful when it comes out. http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html Chris Buddenhagen, Botany Department, Charles Darwin Research Station, Santa Cruz,Galapagos. Mail: Charles Darwin Foundation, Casilla 17-01-3891 Avenida 6 de Diciembre N36-109 y Pasaje California Quito, ECUADOR ______________________________________________________________________ EL CONTENIDO DE ESTE MENSAJE ES DE ABSOLUTA RESPONSABILIDAD DEL AUTOR. FUNDACION CHARLES DARWIN WWW.DARWINFOUNDATION.ORG [[alternative HTML version deleted]]
The book is out--I received mine a few weeks ago. It is very useful. --Matt> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Chris > Buddenhagen > Sent: Friday, September 09, 2005 6:30 AM > To: r-help at stat.math.ethz.ch > Subject: Re: [R] Plot of multiple data sets > > > I found a lot of answers at this type of problem website wrt > graphics and > multiple plots- I bet the book will be useful when it comes out. > > > > http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html > > > > Chris Buddenhagen, Botany Department, Charles Darwin Research > Station, Santa > Cruz,Galapagos. Mail: Charles Darwin Foundation, Casilla > 17-01-3891 Avenida > 6 de Diciembre N36-109 y Pasaje California Quito, ECUADOR > > > > > > > > ______________________________________________________________________ > EL CONTENIDO DE ESTE MENSAJE ES DE ABSOLUTA RESPONSABILIDAD DEL AUTOR. > FUNDACION CHARLES DARWIN > WWW.DARWINFOUNDATION.ORG > [[alternative HTML version deleted]] > > ______________________________________________ > 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 >