[R] dot plot with several points for 2 categories

Michael Knudsen micknudsen at gmail.com
Fri Jul 17 19:54:18 CEST 2009


On Fri, Jul 17, 2009 at 7:17 PM, jaregi<suckale at mpi-cbg.de> wrote:

> I'm trying to wean myself off the very limited capabilities of Excel and Oo.
> Currently, I am trying to make a plot showing several values for 2
> categories in a dot blot (see
> http://www.nabble.com/file/p24538360/Picture%2B1.png Picture+1.png  except
> that the x axis should contain the category not a number, which was the only
> way to coax Excel into displaying a plot like this).

Let y1 be a vector containing the values in the first category, and
let y2 contain those of the second. The you could do like this:

x1 = rep(1,times=length(y1))
x2 = rep(2,times=length(y2))
plot(c(x1,x2),c(y1,y2),xaxt="n")
axis(side=1,at=c(1,2),labels=c("label1","label2"))

It looks like a hack, but it should work.

-- 
Michael Knudsen
micknudsen at gmail.com
http://lifeofknudsen.blogspot.com/




More information about the R-help mailing list