[R] labels inside the bars of horizontal barplot

Albert Vilella avilella at gmail.com
Fri Feb 17 12:57:33 CET 2006


Dears,

I would like to add labels inside the bars of a horizontal bar
plot like this:

mylabels = c(
  "long text goes here first",
  "long text goes here second",
  "long text goes here third",
  "long text goes here fourth",
  "long text goes here fourth",
  "long text goes here fifth",
  "long text goes here sixth",
  "long text goes here seventh",
  "long text goes here bla bla",
  "long text goes here and more"
)
myvect1 = c(0.25,0.21,0.20,0.22,0.20,0.22,0.20,0.22,0.20,0.22)
myvect2 = c(0.13,0.08,0.09,0.11,0.13,0.08,0.09,0.11,0.13,0.08)
mydf = data.frame(myvect1,myvect2) # Forgive this df<->matrix mess, I
use the df for other stuff
barplot(t(as.matrix(mydf)),
        horiz=TRUE,
        beside=TRUE,
        space=c(-0.9,0.1))

What I would like is to have the labels inside the upper bar.

Any ideas?

Bests,

    Albert.




More information about the R-help mailing list