See ?panel.bwplot for pch="|". That explains that pch="|" puts horizontal lines instead of dots at the median(and also at the outliers). The rep makes it into a vector to be indexed by panel.bwplot.intermediate.hh in each of its calls to panel.bwplot
The names under each plot are the levels of the factor, in this example levels(Diet_B). You called them 1:13 in your example. If you want to give them names do so as a factor. For example Control the staples with box.umbrella, again see ?panel.bwplot and ?trellis.par.get The revised example here does all three of your requests. dataN <- data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors <- c("forestgreen", "darkgreen","chocolate1","darkorange2", "sienna2","red2","firebrick3","saddlebrown","coral4", "chocolate4","darkblue","navy","grey38") levels(dataN$Diet_B) <- Diet.colors bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list("Diet of Breeding Ground", cex = 1.4), ylab = list( "Distance between Centers of B and NB Range (1000 km)", cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep("|",13), scales=list(x=list(rot=90)), par.settings=list(box.umbrella=list(lty=1))) On Mon, Sep 24, 2012 at 11:13 PM, Elaine Kuo <elaine.kuo...@gmail.com>wrote: > Hello Richard, > > Your answer is a great help to my problem. > The boxplot of 13 colors is very beautiful :) > > By the way, I have three subsequent questions of your code > > 1. the meaning of pch=rep("|",13) > I read the R manual but could not interpret the part. > "pch" means the point type in plot, but here not sure. > > 2. how to write names under each box > In boxplot, "names" can explain each box, > but here "names" does not work. > > 3. how to make staple from dash to solid line > > Thanks again > > Elaine > > On Tue, Sep 25, 2012 at 7:00 AM, Richard M. Heiberger <r...@temple.edu>wrote: > >> ## I would do this in lattice using the panel.bwplot.intermediate.hh >> ## function from the HH package. >> >> ## install.packages("HH") ## if necessary >> library(HH) >> >> dataN <- data.frame(GE_distance=rnorm(260), >> Diet_B=factor(rep(1:13, each=20))) >> Diet.colors <- c("forestgreen", "darkgreen","chocolate1","darkorange2", >> "sienna2","red2","firebrick3","saddlebrown","coral4", >> "chocolate4","darkblue","navy","grey38") >> bwplot(GE_distance ~ Diet_B, data=dataN, >> xlab=list("Diet of Breeding Ground", cex = 1.4), >> ylab = list( >> "Distance between Centers of B and NB Range (1000 km)", >> cex = 1.4), >> panel=panel.bwplot.intermediate.hh, >> col=Diet.colors, >> pch=rep("|",13)) >> >> >> On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo <elaine.kuo...@gmail.com>wrote: >> >>> Hello, >>> >>> I am making a boxplot of 13 boxes. >>> I tried to color the box using 13 colors but failed. >>> Only red and brown were displayed. >>> Green, blue, and grey disappeared. >>> >>> Please kindly advise modification after checking the code below. >>> Thank you in advance. >>> >>> Elaine >>> >>> R code >>> # data input >>> dataN >>> >>> <-read.csv("H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv",header=T, >>> row.names=1) >>> dim(dataN) >>> dataN[1,] >>> str(dataN) >>> >>> # graph >>> par(mai=c(1,1.03,0.4,0.4)) >>> >>> obs.group<-dataN$Diet_B >>> >>> par(new=T) >>> >>> boxplot(GE_distance~Diet_B, data=dataN,xlab="Diet of Breeding >>> Ground",ylab="", >>> yaxt="n",type="p", >>> pch=1,lwd=0.95, >>> cex.lab=1.4, cex.axis=1.2, >>> font.axis=2, >>> cex=1.5, >>> las=1, >>> bty="l", >>> col=c("forestgreen", >>> "darkgreen","chocolate1","darkorange2","sienna2", >>> "red2","firebrick3", >>> >>> >>> "saddlebrown","coral4","chocolate4","darkblue","navy","grey38")[obs.group])) >>> >>> op = par(mar = c(5,5,4,2) + 0.1) >>> title(ylab = "Distance between Centers of B and NB Range (1000 km)", >>> cex.lab = 1.4,line = 3) >>> >>> axis(side=2,yaxp=c(0,20000,4),cex.lab=1.4, cex.axis=1.2,font.axis=2, >>> las=1) >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> 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. >>> >> >> > [[alternative HTML version deleted]] ______________________________________________ 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.