我正在尝试使用 annotate_custom
在我的绘图之外创建线条以将我的轴分成多个部分。我知道 this post 提出了类似的问题,但出于某种原因,使用负值作为线的最小值不会将线延伸到图之外。
示例代码:
library(ggplot2)
library(grid)
data("iris")
ggplot(iris,aes(x=Species,y=Petal.Width)) +
geom_bar(stat='identity')+coord_flip()+
annotation_custom(grob = linesGrob(),xmin = 2.5,xmax = 2.5,ymin = -90,ymax = 0)+
annotation_custom(grob = linesGrob(),xmin = 1.5,xmax = 1.5,ymax = 0)