How to annotate ggplot2 qplot outside of legend and plotarea? (similar to mtext())

后端 未结 1 1169
自闭症患者
自闭症患者 2020-12-11 02:12

I would like to annotate my plots with a filename. With plot() I used mtext:

plot(1:10)
mtext(\"File xy-12-34-56.csv\", 4)
<         


        
相关标签:
1条回答
  • 2020-12-11 02:57

    Update

    Looks like to achieve the result now we should use the following:

    library(ggplot2)
    library(grid)
    library(gridExtra)
    p <- qplot(data = mtcars, wt, mpg)
    grid.arrange(p, right = textGrob("File xy-12-34-56.csv", rot = -90, vjust = 1))
    

    Old answer

    Try this:

    library(gridExtra)
    p <- qplot(data = mtcars, wt, mpg)
    print(arrangeGrob(p, legend = textGrob("File xy-12-34-56.csv", rot = -90, vjust = 1)))
    

    enter image description here

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