Custom legend with imported images
I'm currently creating plots in ggplot2 by importing custom images and using them as geom_points, similar to this post , except I am looping through different images for unique levels of a factor. Is there an easy way to add these images to the legend? I've seen multiple posts on custom legends in ggplot2, but nothing that deals with imported images. I'm not sure how you will go about generating your plot, but this shows one method to replace a legend key with an image. It uses grid functions to locate the viewports containing the legend key grobs, and replaces one with the R logo library(png)