[R] barplot: width of label

Jim Lemon jim at bitwrit.com.au
Mon Dec 20 11:35:27 CET 2010


On 12/20/2010 02:13 AM, fransiepansiekevertje wrote:
> Hello,
> I try to make barplots with rather wide labels. A simplified example of
> this:
>
> x<- c(12, 33, 56, 67, 15, 66)
> names(x)<- c('Richard with a long surname','Minnie with a long
> name,'Albert','Helen','Joe','Kingston')
> barplot(x, las = 2)
>
> Now the label 'Richard with a long surname' is too long to fit beneath the
> bars. A simple solution would be enlarge the space for the labels by
> positioning the bar region higher. But I cannot find how to do this. Please
> Help!
>
Hi Frans,
Does this do what you want?

library(plotrix)
barp(x,names.arg=names(x),staxx=TRUE)

Jim



More information about the R-help mailing list