Created
October 4, 2018 12:38
-
-
Save trinker/174bb3bc3abb80261582924d4e2472cd to your computer and use it in GitHub Desktop.
Plot images as points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load(ggimage) | |
presidential_icons <- data.frame( | |
x = c(15, 30), | |
y = c(2.5, 4.5), | |
name = c('trump', 'obama'), | |
image = c( | |
'http://www.stickpng.com/assets/images/5841c17aa6515b1e0ad75aa1.png', | |
'http://www.stickpng.com/assets/images/580b57fbd9996e24bc43be4e.png' | |
), | |
size = c(.15, .2) | |
) | |
ggplot2::ggplot(mtcars, aes(mpg, wt)) + | |
ggplot2::geom_point(aes(color = cyl)) + | |
ggimage::geom_image(data = presidential_icons, aes(x = x, y = y, image = image, size = size)) + | |
scale_size(range = c(.15, .2)) |
Author
trinker
commented
Oct 4, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment