Add textbox to facet wrapped layout in ggplot2

后端 未结 2 1164
长发绾君心
长发绾君心 2020-12-09 11:47

I am aware that one is able to annotate a plot created by ggplot2 or even to combine large and small viewports, as is documented in the ggplot2-book. However, it seems that

2条回答
  •  心在旅途
    2020-12-09 12:29

    Since ggplot2 2.2, I've used the caption option instead. You might want to give that a try.

    library(tidyverse)
    
    ggplot(data = mtcars, 
                mapping = aes(y=mpg, x=wt)) +
      geom_point() +
      facet_wrap(c("gear", "cyl"), labeller = "label_both") +
      labs(title = "mtcars analysis",
           subtitle = "This is a subtitle \n",
           caption = "\n Note: This analysis compares the number of gears and cylinders", 
           x = "weight", y = "mpg")
    

    And here's what you'd get:

    ggtest

    I hope that helps you.

提交回复
热议问题