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.
On 02/08/2011 09:14 PM, anoopmj wrote:> > 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. >Hi anoopmj, I'm not sure that I understand what you want to do, but perhaps this will help: HCHO$time<-strptime(HCHO$V1,format="%H:%M:%S") plot(HCHO$time,HCHO$V4,type="h",col=HCHO$colors) HCHO<-read.table("qdoas.qdo",sep="\t") Jim
Hi Anoop, Not sure whether it's too late for you, but is this along the lines of what you want?: x<-0:1000 y<-sin(x/500)+rnorm(1001)/10 z<-cos(x/500)+rnorm(1001)/100 plot(x,y,col=rgb(1,(z-min(z))/(max(z)-min(z)),0)) Or possibly like: plot(x,y,col=rainbow(256)[255*(z-min(z))/(max(z)-min(z))]) Mind that the binning could be done a bit more conscientious ;) Hope it helps, Tsjerk On Wed, Feb 9, 2011 at 6:30 PM, anoopmj <anoopmj at gmail.com> wrote:> > Hi Jim, > > Thanks a lot for the response. I finally decided to do it with ggplot2 > library, qplot and layers. It works pretty well, although I did not know how > to get the time working... so thanks! > > Anoop > -- > View this message in context: http://r.789695.n4.nabble.com/Plot-colour-according-to-column-tp3275655p3297750.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Tsjerk A. Wassenaar, Ph.D. post-doctoral researcher Molecular Dynamics Group * Groningen Institute for Biomolecular Research and Biotechnology * Zernike Institute for Advanced Materials University of Groningen The Netherlands -- Tsjerk A. Wassenaar, Ph.D. post-doctoral researcher Molecular Dynamics Group * Groningen Institute for Biomolecular Research and Biotechnology * Zernike Institute for Advanced Materials University of Groningen The Netherlands
Maybe Matching Threads
- cube root
- Efficient way to Calculate the squared distances for a set of vectors to a fixed vector
- *Building* a covariance matrix efficiently
- Creating 250 submatrices from a large single matrix with 2500 variables using loops
- built a lower triangular matrix from dataframe