[R] dot plot with several points for 2 categories
Steve Lianoglou
mailinglist.honeypot at gmail.com
Fri Jul 17 20:03:18 CEST 2009
Hi,
On Jul 17, 2009, at 1:17 PM, jaregi 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). I started working
> through some tutorials but the example didn't quite fit what I was
> looking
> for. The closest was the car and mpg example but it 1 value per name
> whereas
> I need several value per category. Does anybody know this of the top
> of your
> expert heads? This would be a great help. I already burned a few hours
> without getting closer to the solution..
Something like so?
a <- rnorm(20, 10, 2)
b <- rnorm(20, 15, 1)
plot(jitter(rep(1, length(a))), a, ylim=c(0,20), xlim=c(0,3),
xlab=NULL, xaxt='n')
points(jitter(rep(2, length(b))), b)
axis(1, c(1,2), labels=c('Group 1', 'Group 2'))
Some points:
* plot(..., xaxt='n') -- suppresses plotting of xaxis (see ?par)
* I'm using jitter to add a bit of noise about the x vals so points
don't draw ontop of eachother
HTH,
-steve
--
Steve Lianoglou
Graduate Student: Physiology, Biophysics and Systems Biology
Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list