if (FALSE) {
# Put a silhouette behind a plot
library(ggplot2)
img <- image_data("27356f15-3cf8-47e8-ab41-71c6260b2724", size = "512")[[1]]
qplot(x=Sepal.Length, y=Sepal.Width, data=iris, geom="point") +
add_phylopic(img)
# Put a silhouette anywhere
library(ggplot2)
posx <- runif(50, 0, 10)
posy <- runif(50, 0, 10)
sizey <- runif(50, 0.4, 2)
cols <- sample(c("black", "darkorange", "grey42", "white"), 50,
replace = TRUE)
cat <- image_data("23cd6aa4-9587-4a2e-8e26-de42885004c9", size = 128)[[1]]
(p <- ggplot(data.frame(cat.x = posx, cat.y = posy), aes(cat.x, cat.y)) +
geom_point(color = rgb(0,0,0,0)))
for (i in 1:50) {
p <- p + add_phylopic(cat, 1, posx[i], posy[i], sizey[i], cols[i])
}
p + ggtitle("R Cat Herd!!")
}
Run the code above in your browser using DataLab