对于以下示例,让我想在x轴的值1处添加垂直中心线。我尝试了geom_estci
(http://ggepi.lukewjohnston.com/reference/geom_estci.html),但是我的R找不到geom_estci
函数。我同时安装了ggplot2库和扫帚。我尝试安装ggepi库。但是它不适用于R版本3.6.1。对于以下示例,如何在x = 1处添加垂直中心线?
d=data.frame(drink=c("coffee","tea","water"), mean=c(3,6,2), lower=c(2.6,5.6,1.8),
upper=c(3.5,6.3,2.8))
ggplot() +
geom_errorbarh(data=d, mapping=aes(y=drink, x=upper, xmin=upper, xmax=lower), height=0.2, size=1,
color="blue") +
geom_point(data=d, mapping=aes(y=drink, x=mean), size=4, shape=21, fill="white")
答案 0 :(得分:1)
尝试添加geom_vline(xintercept = 1)
。
ggplot() +
geom_errorbarh(data=d, mapping=aes(y=drink, x=upper, xmin=upper, xmax=lower), height=0.2, size=1,
color="blue") +
geom_point(data=d, mapping=aes(y=drink, x=mean), size=4, shape=21, fill="white") +
geom_vline(xintercept = 1)