Skip to content

Wrapping long labels in barplot(2)

4 messages · Mulholland, Tom, Marc Schwartz, Jan P. Smit

#
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
#
Dear Tom,

Many thanks. I think this gets me in the right direction, but 
concatenates all levels into one long level. Any further thoughts?

Best regards,

Jan
Mulholland, Tom wrote:
#
Building on Tom's reply, the following should work:
[1] This is a long label  1  This is a long label  2 
 [3] This is a long label  3  This is a long label  4 
 [5] This is a long label  5  This is a long label  6 
 [7] This is a long label  7  This is a long label  8 
 [9] This is a long label  9  This is a long label  10
10 Levels: This is a long label  1 ... This is a long label  9
10), collapse = "\n"), USE.NAMES = FALSE)
[1] "This is\na long\nlabel 1"  "This is\na long\nlabel 2" 
 [3] "This is\na long\nlabel 3"  "This is\na long\nlabel 4" 
 [5] "This is\na long\nlabel 5"  "This is\na long\nlabel 6" 
 [7] "This is\na long\nlabel 7"  "This is\na long\nlabel 8" 
 [9] "This is\na long\nlabel 9"  "This is\na long\nlabel 10"
HTH,

Marc Schwartz
On Thu, 2005-04-14 at 16:14 +0700, Jan P. Smit wrote:
#
Dear Marc,

Excellent, this is exactly what I was looking for. The only thing I had 
to change in your code was turning 'short.labels' into a factor.

Many thanks and best regards,

Jan
Marc Schwartz wrote: