How to overlay and position a logo over any R plot (igraph, ggplot2, etc) so I can put branding on it automatically?

前端 未结 1 426
时光说笑
时光说笑 2021-01-17 01:21

I am wondering if there is a generic way to overlay any R plot / visualization appearing in the R output window with a logo (as well as position it) so output is always bran

1条回答
  •  被撕碎了的回忆
    2021-01-17 02:20

    if you are looking for an easy solution, the simplest way to do it would be to overlay your plot with a custom background:

    require(ggplot2); require(grid); require(png);
    data(mtcars)
    # read background image, stacks website logo in this case
    img <- readPNG(source = "so.png")
    # add rater      
    g <- rasterGrob(img, interpolate=TRUE) 
    # Basic plot
    ggplot(mtcars, aes(wt, mpg)) +
        geom_point() +
        annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)
    

    The code would produce the following result: plot_with background Naturally, you can adjust your background by changing the image and placement to make it look more like a proper logo if you wish.

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