# NOT RUN {
x <- rnorm(1000, mean = 10)
y <- rnorm(1000, mean = 20)
color <- sample(1:5, 1000, replace = TRUE)
rastObj <- data.frame(x = x, y = y, color = color) %>%
rasterly(mapping = aes(x = x, y = y, color = color)) %>%
rasterly_points()
p <- rasterly_build(rastObj)
dt <- image2data(p)
if(requireNamespace("ggplot2")) {
# Note that each point represents a single pixel in the image
ggplot2::ggplot(dt, mapping = aes(x = x, y = y)) +
ggplot2::geom_point(color = dt$color, size = 0.5)
}
# }
Run the code above in your browser using DataLab