# Re: [R] reducing the number of x-axis lables in a bwplot while plotting all boxes

From: Cornelis de Gier <cwdegier_at_gmail.com>
Date: Fri, 29 Feb 2008 18:12:44 +0100

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?

Regards,

Cornelis

2008/1/7, Jeff D. Hamann <jeff.hamann_at_forestinformatics.com>:
> 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 ))
>  "20" "40" "60" "80" "100" "120" "140" "160"
>  "180" "200" "220" "240" "260" "280" "300" "320"
>  "340" "360" "380" "400" "420" "440" "460" "480"
>  "500" "520" "540" "560" "580" "600" "620" "640"
>  "660" "680" "700" "720" "740" "760" "780" "800"
>  "820" "840" "860" "880" "900" "920" "940" "960"
>  "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
>
> Thanks,
> Jeff.
>
> --
> Forest Informatics, Inc.
> PO Box 1421
> Corvallis, Oregon 97339-1421
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help