How to add annotation on each facet

前端 未结 1 925
感情败类
感情败类 2021-01-05 06:05

I want to give each facet an alpha code, from A to H since there are eight facets, and draw each code on the top-left of each facet:

ggthemr(\'dust\', layout         


        
相关标签:
1条回答
  • 2021-01-05 06:45
    library(ggplot2)
    
    d <- data.frame(x=rep(1:3, 4), f=rep(letters[1:4], each=3))
    
    labels <- data.frame(f=letters[1:4], label=LETTERS[1:4])
    ggplot(d, aes(x,x)) +
      facet_wrap(~f) +
      geom_point() +
      geom_label(data = labels, aes(label=label), 
                x = Inf, y = -Inf, hjust=1, vjust=0,
                inherit.aes = FALSE)
    

    0 讨论(0)
提交回复
热议问题