I have the following code: subsetTimeDataPlot <- boxplot(subsetTimeData$time ~ subsetTimeData$build, horizontal=True, col="lightblue", ...) The 'names' component consists of strings that can be up to 20-30 characters long. How would I go about drawing the names vertically (not the boxplot) or shrinking the names text (I tried cex.names=0.7 but this didn't help). Thanks for any advice, I apologize if these are stupid questions, -Alex -- Alex Reynolds University of Washington Medical Genetics 2211 Elliot Seattle, WA 98121 areynolds at stamlab.org
Try this: Assuming that 'build' is a factor par(mar=c(7,2,2,2), xpd = TRUE) boxplot(time ~ build, horiz = T, col='lightblue', xaxt='n') text(1:nlevels(build), par("usr")[3]-0.50, levels(build), srt=45, cex=0.6) On 29/02/2008, Alex Reynolds <areynolds at stamlab.org> wrote:> I have the following code: > > subsetTimeDataPlot <- boxplot(subsetTimeData$time ~ > subsetTimeData$build, horizontal=True, col="lightblue", ...) > > The 'names' component consists of strings that can be up to 20-30 > characters long. > > How would I go about drawing the names vertically (not the boxplot) or > shrinking the names text (I tried cex.names=0.7 but this didn't help). > > Thanks for any advice, I apologize if these are stupid questions, > > -Alex > > -- > Alex Reynolds > University of Washington Medical Genetics > 2211 Elliot > Seattle, WA 98121 > areynolds at stamlab.org > > ______________________________________________ > R-help at 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
On Fri, 2008-02-29 at 14:40 -0800, Alex Reynolds wrote:> I have the following code: > > subsetTimeDataPlot <- boxplot(subsetTimeData$time ~ > subsetTimeData$build, horizontal=True, col="lightblue", ...) > > The 'names' component consists of strings that can be up to 20-30 > characters long. > > How would I go about drawing the names vertically (not the boxplot) or > shrinking the names text (I tried cex.names=0.7 but this didn't help). > > Thanks for any advice, I apologize if these are stupid questions,Look at ?par and argument/parameter 'las', which controls the orientation of axis tick labels. You'll also need to increase the margin size on the side of the plot holding the labels if they are very long. For this, see ?par again and parameters 'mar' or 'mai' depending on how you wish to define the margin size. ## Example dat <- data.frame(values = rnorm(100), group = gl(2, 50)) levels(dat$group) <- c("reallyreallylonglabel", "anevenlooooooooooooongerlabel") ## las = 1 gets y-axis labels horizontal, but note note enough room boxplot(values ~ group, data = dat, horizontal = TRUE, las = 1) ## so change the margin on the left (no. 2) ## default is c(5, 4, 4, 2) + 0.1 ## and shrink text size so we don't need a huge margin op <- par(mar = c(5, 10, 4, 2) + 0.1) boxplot(values ~ group, data = dat, horizontal = TRUE, las = 1, cex.axis = 0.7) ## reset the plotting parameters par(op) HTH G> > -Alex >-- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
On Fri, Feb 29, 2008 at 4:40 PM, Alex Reynolds <areynolds at stamlab.org> wrote:> I have the following code: > > subsetTimeDataPlot <- boxplot(subsetTimeData$time ~ > subsetTimeData$build, horizontal=True, col="lightblue", ...) > > The 'names' component consists of strings that can be up to 20-30 > characters long. > > How would I go about drawing the names vertically (not the boxplot) or > shrinking the names text (I tried cex.names=0.7 but this didn't help).You might try: library(ggplot2) qplot(build, time, data=subsetTimeData, geom="boxplot") + coord_flip() which will automatically allocate enough space for the names. You can find out more about ggplot2 at http://had.co.nz/ggplot2. Hadley -- http://had.co.nz/