[R] plot each column of a matrix or dataframe versus x in a single plot

John Kane jrkrideau at yahoo.ca
Fri Feb 15 00:19:38 CET 2008


Perhaps matplot will do what you want?
?matplot
aa <- matrix(1:25, nrow=5)
matplot(aa)

--- tomaschwutz <thomas.wutzler at web.de> wrote:

> How do a plot several columns of a matrix at once in
> a single plot
> versus a single x-variable?
> 
> The default plot.matrix  or plot.dataframe commands
> plot each column
> versus each other column in several sub-plots. I
> want to plot each
> column versus a single other vector (x) as several
> lines or points in
> one plot.
> 
> I can do it by hand: get the range of all variables
> (i.e. columns of
> the matrix or dataframe), initiate an empty plot
> command, loop through
> all the columns and issue a lines or points command.
> I guess there is a predefined sophisticated function
> for that,
> however, I was not able to find it.
> 
> Does someone know where I find such a function?
> 
> Best regards
> tomaschwutz
> 
> ______________________________________________
> 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.
> 



[[elided Yahoo spam]]



More information about the R-help mailing list