Suppose that I have a matrix like: m <- rbind(c(1,2,3,4), c(2,3,2,1)) Is there any way to efficiently plot the _lines_ as if I was doing: plot(m[1,], type="l") points(m[2,], type="l", col="red") (of course, in the "real world" there much more than just 2 lines and 4 columns...) Alberto Monteiro
Try this: matplot(t(m), type='l', lty = 'solid', col='black') On 6/6/08, Alberto Monteiro <albmont@centroin.com.br> wrote:> > Suppose that I have a matrix like: > > m <- rbind(c(1,2,3,4), c(2,3,2,1)) > > Is there any way to efficiently plot the _lines_ as if > I was doing: > > plot(m[1,], type="l") > points(m[2,], type="l", col="red") > > (of course, in the "real world" there much more than > just 2 lines and 4 columns...) > > Alberto Monteiro > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
On 6/6/2008 3:01 PM, Alberto Monteiro wrote:> Suppose that I have a matrix like: > > m <- rbind(c(1,2,3,4), c(2,3,2,1)) > > Is there any way to efficiently plot the _lines_ as if > I was doing: > > plot(m[1,], type="l") > points(m[2,], type="l", col="red") > > (of course, in the "real world" there much more than > just 2 lines and 4 columns...)m <- rbind(c(1,2,3,4), c(2,3,2,1)) matplot(t(m), type="l") ?matplot> Alberto Monteiro > > ______________________________________________ > 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.-- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894