Annotate outside plot area once in ggplot with facets

后端 未结 4 1160
粉色の甜心
粉色の甜心 2021-01-18 17:25

I want to add an annotation outside the plotting area in a faceted ggplot. I can get the annotation that I want, but it\'s repeated for each facet. How can I get this annota

4条回答
  •  轮回少年
    2021-01-18 17:55

    With geom_text:

    dummy <- data.frame(cyl = c(4), l = c("XX"), stringsAsFactors = F)
    
    ggplot(mtcars, aes(x = hp, y = mpg)) +
      geom_point() +
      geom_text(data=dummy, aes(label=l), x = -20, y = 36) +
      facet_grid(.~cyl ) + 
      coord_cartesian(xlim = c(50, 350), ylim = c(10, 35), clip = "off")
    

提交回复
热议问题