I want to add an image or svg to the ggplot title.
This is what I'm aiming for:
get the eye "here"
Below is my best try.
I'm unhappy with it because I have to try and error a lot to get it into the right position. not really a general solution.
library(ggplot2)
library(raster)
library(grid)
img1 <- as.matrix(raster(system.file("external/rlogo.grd", package="raster")))
img1[img1>128] <- NA
img1[img1>0] <- 0
image(img1)
g1 <- rasterGrob(img1, interpolate=TRUE)
p <- ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
ggtitle(" <- dat rLogo tho") +
annotation_custom(g1,xmin = 1.2,1.6,35.5,38)
gt <- ggplot_gtable(ggplot_build(p))
gt$layout$clip[gt$layout$name == "panel"] <- "off"
grid.draw(gt)


