Jeff D. Hamann
2008-Jan-07 20:23 UTC
[R] reducing the number of x-axis lables in a bwplot while plotting all boxes
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
Cornelis de Gier
2008-Feb-29 17:12 UTC
[R] reducing the number of x-axis lables in a bwplot while plotting all boxes
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 )) > [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 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. >
Deepayan Sarkar
2008-Feb-29 17:50 UTC
[R] reducing the number of x-axis lables in a bwplot while plotting all boxes
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