[R] rotated labels in barplot with beside=T and multiple groups
Karin Lagesen
karin.lagesen at medisin.uio.no
Tue Feb 21 14:07:35 CET 2006
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 at medisin.uio.no
http://www.cmbn.no/rognes/
More information about the R-help
mailing list