Add image (png file) to header of pdf file created with R

后端 未结 1 1896
小鲜肉
小鲜肉 2020-12-16 05:50

I am trying to add an .png image (logo) to the header of my pdf report of graphs created with ggplot and printed to pdf.

I found the following example how to add a i

相关标签:
1条回答
  • 2020-12-16 06:45

    here's a suggestion,

    library(ggplot2)
    p.example = qplot(mpg, wt, data = mtcars)
    
    library(grid)
    library(gtable)
    ann <- rasterGrob(mypng, width=unit(1,"cm"), x = unit(0.5,"cm"))
    g <- ggplotGrob(p.example)
    
    g <- gtable_add_rows(g, grobHeight(ann), 0)
    g <- gtable_add_grob(g, ann, t=1, l=4)
    grid.newpage()
    grid.draw(g)
    

    enter image description here

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