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

Deepayan Sarkar deepayan.sarkar at gmail.com
Fri Feb 29 18:50:04 CET 2008


On 1/7/08, Jeff D. Hamann <jeff.hamann at forestinformatics.com> wrote:
> 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?

You can supply blank labels; e.g.,

xlim = c("20", "", "", "", "100", ...)

-Deepayan



More information about the R-help mailing list