Xiao Shi
2005-May-11 15:26 UTC
[R] How to plot a matrix with 18 rows by row vs. a vector in a single graph, resulting 18 lines with different colors?
I have a matrix gene=array(rnorm(180), dim=c(18,10)) and a vector time=c(0, 0.5,2,4,6,8,12,24,48,72). So i can get a plot with plot(time,gene[1,],type="b",col="green") for the first row.So how can i get all the 18 rows in the same plot VS. the same vector time=c(0,0.5,2,4,6,8,12,24,48,72). Any suggestions.Thanks ! [[alternative HTML version deleted]]
Spencer Graves
2005-May-11 15:37 UTC
[R] How to plot a matrix with 18 rows by row vs. a vector in a single graph, resulting 18 lines with different colors?
Have you considered "matplot": matplot(1:3, array(1:6, dim=c(3,2)), type="b") spencer graves Xiao Shi wrote:> I have a matrix gene=array(rnorm(180), dim=c(18,10)) and a vector time=c(0, > 0.5,2,4,6,8,12,24,48,72). > So i can get a plot with plot(time,gene[1,],type="b",col="green") for the > first row.So how can i get all the 18 rows in the same plot VS. the same > vector time=c(0,0.5,2,4,6,8,12,24,48,72). > Any suggestions.Thanks ! > > [[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
Liaw, Andy
2005-May-11 15:41 UTC
[R] How to plot a matrix with 18 rows by row vs. a vector in a single graph, resulting 18 lines with different colors?
See ?matplot. E.g., matplot(time, t(gene), type="b", lty=1) Andy> From: Xiao Shi > > I have a matrix gene=array(rnorm(180), dim=c(18,10)) and a > vector time=c(0, > 0.5,2,4,6,8,12,24,48,72). > So i can get a plot with > plot(time,gene[1,],type="b",col="green") for the > first row.So how can i get all the 18 rows in the same plot > VS. the same > vector time=c(0,0.5,2,4,6,8,12,24,48,72). > Any suggestions.Thanks ! > > [[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 > > >
Romain Francois
2005-May-11 15:47 UTC
[R] How to plot a matrix with 18 rows by row vs. a vector in a single graph, resulting 18 lines with different colors?
Le 11.05.2005 17:26, Xiao Shi a ??crit :>I have a matrix gene=array(rnorm(180), dim=c(18,10)) and a vector time=c(0, >0.5,2,4,6,8,12,24,48,72). >So i can get a plot with plot(time,gene[1,],type="b",col="green") for the >first row.So how can i get all the 18 rows in the same plot VS. the same >vector time=c(0,0.5,2,4,6,8,12,24,48,72). >Any suggestions.Thanks ! > >Hello, matplot(time,t(gene),type="o") BTW, time is the name of an R function. Choose something else if you don't want funny things to happen. Romain -- ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~ 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 ~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~