RE: [R] Wrapping long labels in barplot(2)

From: Mulholland, Tom <Tom.Mulholland_at_dpi.wa.gov.au>
Date: Thu 14 Apr 2005 - 14:14:51 EST


This may not be the best way but in the past I think I have done something like

levels(x) <- paste(strwrap(levels(x),20,prefix = ""),collapse = "\n")

Tom

> -----Original Message-----
> From: Jan P. Smit [mailto:janpsmit@gmail.com]
> Sent: Thursday, 14 April 2005 11:48 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Wrapping long labels in barplot(2)
>
>
> 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.
>
> Jan Smit
>
> Consultant
> Economic and Social Commission for Asia and the Pacific
>
> ______________________________________________
> R-help@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
>



R-help@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 Received on Thu Apr 14 14:19:18 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:10 EST