CRSouser
CRSouser

Reputation: 678

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

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 branded?

I read this post where they use a stripe banner as part of ggplot, but is there more of a generic way of doing this so I can include it in any output to automatically put the appropriate branding in particular location (realizing it will likely have to be adjusted, but at least so it is always there) so I cna have it be part of say the 'default code template' so whether I or my colleague use generic plot, igraph, ggplot2, or any other graphics package it always will always get overlayed?

Upvotes: 0

Views: 1106

Answers (1)

Konrad
Konrad

Reputation: 18585

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.

Upvotes: 1

Related Questions