[R] draw a graphic using segments to represent data

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed May 10 12:12:56 CEST 2006


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




More information about the R-help mailing list