[R] Boxplot names

S Ellison S.Ellison at LGCGroup.com
Thu Jul 19 18:18:30 CEST 2012


> When i make Boxplots with a lot of boxes, the names of them 
> get only written down every second "column".
> Since they aren't in any way ordered, you don't see anymore 
> to what they belong.

Jessica,

Another possibility if the names are long is to use abbreviated factor levels. The labels appear when there is room; they are only omitted if there isn't space. So you could use  something like

y <- rnorm(55)
g <- factor(paste("Unduly long factor level name", rep(1:5, each=11)))

boxplot(y~g) #Not useful

ga <- g
levels(ga) <- abbreviate(levels(g))
boxplot(y~ga) #Much better

If you don't want to change the actual factor level labels, use something like

boxplot(y~g, axes=FALSE, at=1:nlevels(g))
box()
axis(2)
axis(1, at=1:nlevels(g), labels=abbreviate(levels(g)))
# or 
axis(1, at=1:nlevels(g), labels=abbreviate(levels(g)), las=2) #vertical text


S Ellison

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list