[R] Plot colour according to column

anoopmj anoopmj at gmail.com
Tue Feb 8 11:14:30 CET 2011


Hi,

I am trying to plot several columns in different graphs in columns and rows.
The first column of my data file is the time, and the third is the
'elevation angle' with 19 different numbers. I would like to plot the rest
of the columns with the x axis as time and the individual angles in
different colours.

Here is the code I am using right now. It plots the different columns with
time, but I didn't know how to make the third column as the colour filter.

------
maduplot<-function(mydata) {
par(mfrow=c(5,3),mar=c(2,2,2,2)) 

for(i in 2:ncol(mydata)) {
plot(mydata[,i]~mydata[,1]
,type="l" 
,xlab=colnames(mydata)[1]
,ylab=colnames(mydata)[i]
,main=colnames(mydata)[i])

grid(col="black",lwd=0.2,lty=1) 
}
}

HCHO <-read.table("qdoas.qdo", header=TRUE)

maduplot(HCHO)

------

A sample dataset is attached.

http://r.789695.n4.nabble.com/file/n3275655/QDOAS.qdo QDOAS.qdo 
-- 
View this message in context: http://r.789695.n4.nabble.com/Plot-colour-according-to-column-tp3275655p3275655.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list