[R] rotated labels in barplot with beside=T and multiple groups

From: Karin Lagesen <karin.lagesen_at_medisin.uio.no>
Date: Wed 22 Feb 2006 - 00:07:35 EST

I have a data set that I display using barplot. I don't know what you call it, but when I look at it, it looks like this:

> lsu
   

    (0,0.1] (0.1,0.2] (0.2,0.3] (0.3,0.4] (0.4,0.5] (0.5,0.6]

  A 0.052631579 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
  B 0.000000000 0.000000000 0.001007049 0.003021148 0.000000000 0.000000000
  E 0.200000000 0.000000000 0.000000000 0.000000000 0.100000000 0.000000000
   

    (0.6,0.7] (0.7,0.8] (0.8,0.9] (0.9,1]

  A 0.000000000 0.000000000 0.000000000 0.947368421
  B 0.000000000 0.004028197 0.005035247 0.986908359
  E 0.100000000 0.000000000 0.100000000 0.500000000

>

Now, trying the examples shown via the r-help mailing list I am trying to make a plot where each of the groups gets displayed in a histogram-like fashion upwards with the number 0.1, 0.2 and so forth underneath the group. What I do is the following:

> par(mar = c(6, 4, 4, 2) + 0.1)
> bplot = barplot(lsu, beside=TRUE, col=colors[1:length(lsu[,1])], ylim = c(0,1.0), xaxt = "n", xlab = "")
> axis(side=1,at=bplot, labels=FALSE, tick=TRUE)
NULL
> nam=rep("a",10)
> text(bplot, par("usr")[3] - 1.5, srt = 45, adj = 1, labels = nam, xpd = TRUE)
NULL
>

The result is the bars pointing upwards, like I want, but I get one tickmark per bar, and no labels underneath. I want no tickmark, and one label per group.

Any ideas as to what I am doing wrong?

TIA, Karin

-- 
Karin Lagesen, PhD student
karin.lagesen@medisin.uio.no
http://www.cmbn.no/rognes/

______________________________________________
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 Feb 22 00:13:18 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:38 EST