Re: [R] draw a graphic using segments to represent data

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Wed 10 May 2006 - 20:12:56 EST

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@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



R-help@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 Received on Wed May 10 20:21:07 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 May 2006 - 22:10:04 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.