Using annotate to add different annotations to different facets

后端 未结 1 1971
日久生厌
日久生厌 2020-12-05 18:53

I\'m trying to add panel labels to different facets in a plot. I want them to be 1:7, but, the following code

d <- ggplot(diamonds, aes(carat, price, fil         


        
相关标签:
1条回答
  • 2020-12-05 19:48

    With annotate, you can't. But by setting up a data.frame and using it as the data source for a geom_text, it is easy (with a few bookkeeping aspects).

    d1 + geom_text(data=data.frame(x=0.25, y=1.5e+04, label=1:7, 
                                   color=c("D","E","F","G","H","I","J")), 
                   aes(x,y,label=label), inherit.aes=FALSE)
    

    enter image description here

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