# Plot with base R
plot(logo)
# Plot image with ggplot2
library(ggplot2)
myplot <- image_ggplot(logo)
myplot + ggtitle("Test plot")
# Show that coordinates are reversed:
myplot + theme_classic()
# Or add to plot as annotation
image <- image_fill(logo, 'none')
raster <- as.raster(image)
myplot <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
myplot + annotation_raster(raster, 25, 35, 3, 5)
# Or overplot image using grid
library(grid)
ggplot(cars, aes(speed, dist)) + geom_point() + geom_smooth()
grid.raster(image)
Run the code above in your browser using DataLab