On Fri, 2008-02-29 at 18:12 +0100, Cornelis de Gier wrote: > I'm looking for an answer to a similar question: > > years <- as.factor(sort(rep(1987:2006,20))) > values <- rnorm(1:400,0,10) > plot(years,values) > > results in 20 boxplots with x axis labels unreadable because there are > too many of them. How do I reduce the number of x axis labels?
Hmm, if I follow that in an R session, I get very readable x-axis labels as not all boxplots are labelled - only those that can be accommodated given the current size of the device. You could try: plot(years,values, las = 3) to rotate the year labels. If your real example has very long labels, then you will need to create more margin space, see ?par Alternative, you can cook your own axis: bxp.res <- boxplot(values ~ years, axes = FALSE) ## axis side 2 axis(2) ## choose every third year year.want <- seq(from = 1, by = 3, length.out = length(unique(years))) ## draw axis, label at correct locations with correct year label axis(1, at = year.want, labels = unique(years)[year.want]) ## draw the frame box() HTH G > > Regards, > > Cornelis > > > 2008/1/7, Jeff D. Hamann <[EMAIL PROTECTED]>: > > I apologize if this is somewhere in the archives, but I can't seem to find > > a solution to this question. > > > > I've been trying to plot a bwplot: > > > > print( > > bwplot( n.pareto ~ as.factor(gen) | mut.rate * n.pop, > > data=p6, > > horizontal=FALSE, > > box.ratio=0.75, > > cex=0.6, > > xlim=c(-1,51), > > ylim=c(-1,500), > > layout=c(3,3), > > index.cond=list(c(1,2,3),c(3,2,1)), > > panel = function(...) { > > panel.grid(v = -1, h = -1) > > cex=0.05 > > panel.bwplot(...) > > panel.abline(h=486,lty=2) > > }, > > main="Non-dominated Pareto Optimal Solutions", > > ylab="Non-dominated Solutions in the Pareto Archive", > > xlab="Generation" ) > > ) > > > > which works "fine", but... I have tried almost every combination of > > pertinent arguments for reducing the number of ticks/lables while still > > plotting all the boxes in each panel. The levels of "gen" are: > > > > > levels( as.factor(p6$gen )) > > [1] "20" "40" "60" "80" "100" "120" "140" "160" > > [9] "180" "200" "220" "240" "260" "280" "300" "320" > > [17] "340" "360" "380" "400" "420" "440" "460" "480" > > [25] "500" "520" "540" "560" "580" "600" "620" "640" > > [33] "660" "680" "700" "720" "740" "760" "780" "800" > > [41] "820" "840" "860" "880" "900" "920" "940" "960" > > [49] "980" "1000" > > > > > > > which creates a "smear" of labels across the x axis. My problem is that I > > would like to only print five or 10 of the labels (i.e. > > 20,100,200,...,900) or something to make the labels readable and still > > plot all the boxes in each panel. > > > > Is there something I'm missing as a result conditioning on two factors. I > > feel like such a newbie about this... ugh... Any hints, please? > > > > Thanks, > > Jeff. > > > > -- > > Forest Informatics, Inc. > > PO Box 1421 > > Corvallis, Oregon 97339-1421 > > > > ______________________________________________ > > 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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ 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.