How can I add a logo to a ggplot visualisation?
You could use the
cowplot package to easily add an image to any plot made with
ggplot. I used the R logo as the image that needs to be added to the plot (using
magick package to read it). One advantage of using
cowplot is that you can easily specify the size and position of both the plot and the image.
library(cowplot) library(magick) img <- image_read("Logo.png") # Set the canvas where you are going to draw the plot and the image ggdraw() + # Draw the plot in the canvas setting the x and y positions, which go from 0,0 # (lower left corner) to 1,1 (upper right corner) and set the width and height of # the plot. It's advisable that x + width = 1 and y + height = 1, to avoid clipping # the plot draw_plot(p,x = 0, y = 0.15, width = 1, height = 0.85) + # Draw image in the canvas using the same concept as for the plot. Might need to # play with the x, y, width and height values to obtain the desired result draw_image(img,x = 0.85, y = 0.02, width = 0.15, height = 0.15)