You can use strwrap and paste to insert newlines into your labels. E.g., > wrapped <- function(strings, width) vapply(strings, > function(s)paste(collapse="\n", strwrap(s, width)), FUN.VALUE="", > USE.NAMES=FALSE) > par(mfrow=c(2,1)) > barplot(structure(11:15, names=wrapped(state.name[31:35], 6))) > barplot(structure(11:15, names=state.name[31:35])) > wrapped(state.name[31:35], 6) [1] "New\nMexico" "New\nYork" "North\nCarolina" "North\nDakota" [5] "Ohio"
strwrap, hence the above wrapped, uses units of characters, not cm. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Kyle. > Sent: Friday, April 27, 2012 11:35 AM > To: RHelp > Subject: [R] Wrap names.arg text in barplot > > Hello! > > Does anyone know of a handy way to wrap the names.arg text in a barplot? > I'm creating a bar plot with rather long labels; I can adjust the margins, > but I'd also like to have the text wrap to about 4cm. Thanks! > > > Kyle H. Ambert > Doctoral Candidate, Bioinformatics > Oregon Health & Science University > ambe...@gmail.com > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.