[R] Finishing details of dotplot
Ben Bolker
bolker at ufl.edu
Tue Aug 12 20:34:39 CEST 2008
John Poulsen <jpoulsen <at> zoo.ufl.edu> writes:
>
> Hello,
>
> I am trying to create a dotplot, and have run into a couple of snags
> with the finishing details. The below code creates the dotplot, but I
> cannot figure out how to: 1) change the color of the CI bars to black,
> not blue, 2) delete the horizontal dotplot lines, and 3) arrange the
> parameters in the order that they are listed in the par vector below,
> rather than having them be arranged alphabetically.
>
> Thanks for any help you can give.
Hi John ...
library(Hmisc)
e.test=c(0.42, -0.39, 0.16, 0.15, 0.58, 0.32, 0.55, 0.12, -0.14, -0.44,
0.15, 0.16, 1.2, 1.34, 0.42, 1.02)
sd.test=c(0.023, 0.053, 0.109, 0.109, 0.047, 0.038, 0.04, 0.035, 0.054,
0.141, 0.086, 0.085, 0.131, 0.114, 0.131, 0.111)
lower=e.test - (sd.test * 1.96)
upper=e.test + (sd.test * 1.96)
spp=rep(c("D", "M"), each=8)
par=rep(c("Ind","For","LR","SR","Lnd","Nd1","Nd2","Pkl"),2)
res=data.frame(e.test,sd.test,lower,upper,spp,par)
## rearrange factor into preferred order
res$par <- factor(as.character(res$par),levels=unique(par))
## set CI lines to black
t1 = trellis.par.get("plot.line")
t1$col <- "black"
trellis.par.set("plot.line",t1)
## turn off grid lines
d1 <- trellis.par.get("dot.line")
d1$lwd <- 0 ## hack -- set line width to 0
trellis.par.set("dot.line",d1)
Dotplot(par~Cbind(e.test, lower, upper)|spp, data=res,
pch=16, col="black", method="bars",
ylab="Parameters", xlab="Estimate",
panel=function(x,y){
panel.Dotplot(x, y, col="black",
panel.abline(v=1, lty=2))},
strip=strip.custom(style=1, bg="lightgrey"))
cheers
Ben
More information about the R-help
mailing list