将段添加到 ggplot2 中的条形图(离散 x 轴)

add segments to barchart (discrete x-axis) in ggplot2

我正在尝试使用 ggplot2 在条形图的每个条上绘制线段。我知道如何使用连续的 X 轴执行此操作,但不知道如何使用此离散轴。 我所做的是一种 "hack" 通过用文本组成一行。

它在图片中看起来不错,但我没有得到 "limit" 金属浓度的图例,最重要的是,每次放大或缩小时,片段的长度都会改变。

有谁知道哪种几何图形可以更好地实现这一点?

df = data.frame('metal'=c("Cu", "Fr", "Zn"), 'observed'=c(550, 60, 100), 'limit'=c(200, 150, 120))
ggplot(data=df) + aes(x=metal) + 
  geom_bar(aes(y=observed), stat="identity", fill="grey") +
  geom_text(aes(y=limit, label="_____________"), size=rel(6), color="red")

编辑:

问题接近一个

这是一个方法。

ggplot(data=df) + aes(x=metal) + 
  geom_bar(aes(y=observed), stat="identity", fill="grey", color = "grey60") +
  geom_bar(data = df, aes(y=limit), stat="identity", fill="transparent", color = "grey30") +
  geom_text(aes(y = limit +5), label = df$limit)

改编自

ggplot(data=df) + aes(x=metal) + 
  geom_bar(aes(y=observed), stat="identity", fill="grey") +
  geom_errorbar(aes(y=limit,ymin=limit,ymax=limit,colour="limit"))