[R] labels inside the bars of horizontal barplot

Jacques VESLOT jacques.veslot at cirad.fr
Fri Feb 17 13:09:39 CET 2006


b <- barplot(t(as.matrix(mydf)),horiz=TRUE,beside=TRUE,space=c(-0.9,0.1))
text(myvect1, b[1,], mylabels, col="white", adj=1)


Albert Vilella a écrit :

>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.
>
>______________________________________________
>R-help at 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
>
>  
>




More information about the R-help mailing list