我正在dotplot()使用lattice或Dotplot()使用Hmisc.当我使用默认参数时,我可以绘制没有小垂直结束的误差条
--O -
但我想得到
| --O - |
我知道我能得到
| --O - |
当我使用centipede.plot()从plotrix或segplot()从latticeExtra,但这些解决方案并没有给我这么好的调理选项Dotplot().我试图用玩par.settings的plot.line,这对于改变错误条线的颜色,宽度等效果很好,但到目前为止,我一直在增加垂直的结局是不成功的:
require(Hmisc)
mean = c(1:5)
lo = mean-0.2
up = mean+0.2
d = data.frame (name = c("a","b","c","d","e"), mean, lo, up)
Dotplot(name ~ Cbind(mean,lo,up),data=d,ylab="",xlab="",col=1,cex=1,
par.settings = list(plot.line=list(col=1),
layout.heights=list(bottom.padding=20,top.padding=20)))
Run Code Online (Sandbox Code Playgroud)

请不要给我使用ggplot2的解决方案......
我过去也有同样的需求,barchart()而不是Dotplot().
我的解决方案是创建一个自定义面板功能:(1)首先执行原始面板功能; (2)然后用于panel.arrows()添加误差条(使用双头箭头,其中头部的边缘与轴形成90度角).
以下是这可能是什么样的Dotplot():
# Create the customized panel function
mypanel.Dotplot <- function(x, y, ...) {
panel.Dotplot(x,y,...)
tips <- attr(x, "other")
panel.arrows(x0 = tips[,1], y0 = y,
x1 = tips[,2], y1 = y,
length = 0.15, unit = "native",
angle = 90, code = 3)
}
# Use almost the same call as before, replacing the default panel function
# with your customized function.
Dotplot(name ~ Cbind(mean,lo,up),data=d,ylab="",xlab="",col=1,cex=1,
panel = mypanel.Dotplot,
par.settings = list(plot.line=list(col=1),
layout.heights=list(bottom.padding=20,top.padding=20)))
Run Code Online (Sandbox Code Playgroud)
