Hello, I'd like to draw a graphic using different color line segments to represent microarray data. It simply likes this: Data=cbind(c(1, 2, -1, 3, -2.2), c(1, 3, -1, -1.8, 4)) The first col No represents y'axis position (negative down and positive up). The second col No represents a length of segment (negative segment should be on left of y, and positive on right). Also the segment color on I, II, III, IV should be different. Thank you for your time and help. Xueato [[alternative HTML version deleted]]
Wang, Xuetao wrote:> Hello, > > > > I'd like to draw a graphic using different color line segments to > represent microarray data. It simply likes this: > > Data=cbind(c(1, 2, -1, 3, -2.2), c(1, 3, -1, -1.8, 4)) > > The first col No represents y'axis position (negative down and positive > up). The second col No represents a length of segment (negative segment > should be on left of y, and positive on right). Also the segment color > on I, II, III, IV should be different. >Something like myplot <- function(x, y, segcol=1:4, col, ...){ plot(x, y, type="n", ...) abline(h=0, v=0, col="grey", ...) if(missing(col)) col <- segcol[1 + (x > 0) + 2 * (y > 0)] segments(x, y, 0, y, col = col, ...) } myplot(Data[,1], Data[,2]) springs to mind.> > Thank you for your time and help. > > > > Xueato > > > [[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
Camarda, Carlo Giovanni
2006-May-10 11:01 UTC
[R] draw a graphic using segments to represent data
Hi,
I am not sure whether I completely understood your question. Anyway,
here it's a simple code that, hopefully, overcome your problem.
Data=cbind(c(1, 2, -1, 3, -2.2), c(1, 3, -1, -1.8, 4))
plot(x=rep(0,nrow(Data)), Data[,1], axes=F, xlim=c(-max(Data[,2]),
max(Data[,2])), xlab="", col=1:nrow(Data), cex=2)
axis(2)
for(i in 1:nrow(Data)){
segments(x0=0, y0=Data[i,1], x1=Data[i,1] + Data[i,2], y1=Data[i,1],
col=i)
}
Best,
Carlo Giovani Camarda
==========================================Camarda Carlo Giovanni
PhD-Student
Max Planck Institute for Demographic Research
Konrad-Zuse-Strasse 1
18057 Rostock, Germany
Tel: +49 (0)381 2081 172
Fax: +49 (0)381 2081 472
camarda@demogr.mpg.de
==========================================
Date: Tue, 9 May 2006 15:10:37 -0400
From: "Wang, Xuetao" <Xuetao.Wang@childrens.harvard.edu>
Subject: [R] draw a graphic using segments to represent data
To: r-help@stat.math.ethz.ch
Message-ID:
<FE0A8E789155874B84394D4C1EED8A8D041A7BDB@CHEXV1.CHBOSTON.ORG>
Content-Type: text/plain
Hello,
I'd like to draw a graphic using different color line segments to
represent microarray data. It simply likes this:
Data=cbind(c(1, 2, -1, 3, -2.2), c(1, 3, -1, -1.8, 4))
The first col No represents y'axis position (negative down and positive
up). The second col No represents a length of segment (negative segment
should be on left of y, and positive on right). Also the segment color
on I, II, III, IV should be different.
Thank you for your time and help.
Xueato
----------
This mail has been sent through the MPI for Demographic Rese...{{dropped}}