在 stackexchange 的讨论中,我尝试实现以下情节
从
Cumming, G. 和 Finch, S. (2005)。[通过眼睛推断:置信区间和如何读取数据图片][5]。美国心理学家,60(2),170-180。doi:10.1037/0003-066X.60.2.170
我和一些人一样不喜欢双轴,但我认为这是一个合理的使用。
在我的部分尝试之下,第二个轴仍然缺失。我正在寻找更优雅的替代品,欢迎智能变化。
library(lattice)
library(latticeExtra)
d = data.frame(what=c("A","B","Difference"),
mean=c(75,105,30),
lower=c(50,80,-3),
upper = c(100,130,63))
# Convert Differences to left scale
d1 = d
d1[d1$what=="Difference",-1] = d1[d1$what=="Difference",-1]+d1[d1=="A","mean"]
segplot(what~lower+upper,centers=mean,data=d1,horizontal=FALSE,draw.bands=FALSE,
lwd=3,cex=3,ylim=c(0,NA),pch=c(16,16,17),
panel = function (x,y,z,...){
centers = list(...)$centers
panel.segplot(x,y,z,...)
panel.abline(h=centers[1:2],lty=3)
} )
## How to add the right scale, close to the last bar?