Message-ID: <425F993A.7030401@ozemail.com.au>
Date: 2005-04-15T10:36:42Z
From: Jim Lemon
Subject: Wrapping long labels in barplot(2)
In-Reply-To: <425DE7D5.9040304@srres.com>
Jan P. Smit wrote:
> I am using barplot, and barplot2 in the gregmisc bundle, in the
> following way:
>
> barplot2(sort(xtabs(expend / 1000 ~ theme)),
> col = c(mdg7, mdg8, mdg3, mdg1), horiz = T, las = 1,
> xlab = "$ '000", plot.grid = T)
>
> The problem is that the values of 'theme', which is a factor, are in
> some cases rather long, so that I would like to wrap/split them at a
> space once they exceed, say, 20 characters. What I'm doing now is
> specifying names.arg manually with '\n' where I want the breaks, but I
> would like to automate the process.
>
> I've looked for a solution using 'strwrap', but am not sure how to apply
> it in this situation.
>
You may find the staxlab function in the plotrix package to be helpful.
It STaggers AXis LABels to allow fairly long strings to be displayed
without overlapping.
Jim