Plotting images while removing any that have overlap

Hi,

So I have this really basic example of using geom_image. What I would like to achieve is to not plot those images which will have overlap in the graphic based on overlap in pixels between two images or more. Is there some way to perform this?

Is there maybe a way of converting said images into boxes or shapes and first see if there will be any overlap?

See my basic plot below:

library("ggplot2")
library("ggimage")

# create a df

set.seed(2017-02-21)
d <- data.frame(x = rnorm(10),
                y = rnorm(10),
                image = sample(c("https://www.r-project.org/logo/Rlogo.png",
                                 "https://jeroenooms.github.io/images/frink.png"),
                               size=10, replace = TRUE)
)
# plot2
ggplot(d, aes(x, y)) + geom_image(aes(image=image), size=.08)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.