library(ggplot2)
library(magick)
library(here) # For making the script run without a wd
library(magrittr) # For piping the logo
# Make a simple plot and save it
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point() +
ggtitle("Cars") +
ggsave(filename = paste0(here("/"), last_plot()$labels$title, ".png"),
width = 5, height = 4, dpi = 300)
# Call back the plot
# Now call back the plot
background <- image_read(paste0(here("/"), "Cars.png"))
# And bring in a logo
logo_raw <- image_read("https://i.imgur.com/e1IneGq.jpg")
frames <- lapply(logo_raw, function(frame) {
image_composite(background, frame, offset = "+70+800")
})
animation <- image_animate(image_join(frames))
image_write(animation, "~/Cars_Travolta.gif")
स्रोत
2017-07-11 23:15:20
'annotation_raster':बस भयानक पैकेज Magick है, जो भी एक GIF ggplot छवियों पर आच्छादित करने की अनुमति देगा से एक अद्यतन जोड़ने। उदाहरण देखें [यहां] (http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf) – mnel
धन्यवाद @mnel! मुझे अभी भी 'readotNG' और 'download.file (..., mode = 'wb' के साथ 'annotation_raster' – Maiasaura