{"action":"created","issue":{"url":"https://api.github.com/repos/yihui/animation/issues/91","repository_url":"https://api.github.com/repos/yihui/animation","labels_url":"https://api.github.com/repos/yihui/animation/issues/91/labels{/name}","comments_url":"https://api.github.com/repos/yihui/animation/issues/91/comments","events_url":"https://api.github.com/repos/yihui/animation/issues/91/events","html_url":"https://github.com/yihui/animation/issues/91","id":223804012,"node_id":"MDU6SXNzdWUyMjM4MDQwMTI=","number":91,"title":"Question: Transparent background","user":{"login":"grssnbchr","id":2305708,"node_id":"MDQ6VXNlcjIzMDU3MDg=","avatar_url":"https://avatars2.githubusercontent.com/u/2305708?v=4","gravatar_id":"","url":"https://api.github.com/users/grssnbchr","html_url":"https://github.com/grssnbchr","followers_url":"https://api.github.com/users/grssnbchr/followers","following_url":"https://api.github.com/users/grssnbchr/following{/other_user}","gists_url":"https://api.github.com/users/grssnbchr/gists{/gist_id}","starred_url":"https://api.github.com/users/grssnbchr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grssnbchr/subscriptions","organizations_url":"https://api.github.com/users/grssnbchr/orgs","repos_url":"https://api.github.com/users/grssnbchr/repos","events_url":"https://api.github.com/users/grssnbchr/events{/privacy}","received_events_url":"https://api.github.com/users/grssnbchr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-04-24T12:32:22Z","updated_at":"2018-08-22T07:10:41Z","closed_at":null,"author_association":"NONE","body":"This is a question, not a bug report. I want to generate a GIF with ggplot2 and a transparent background. Even though I set the background to \"transparent\" in ggplot2's `theme` function, I don't get a transparent background in the final GIF. Is there an option which sets this? Or is this not even possible directly with `saveGIF`? \r\n\r\n```\r\nplotIteration <- function(frame) {\r\n  current_df <- frame_dfs[[frame]]\r\n  p <- ggplot() +\r\n    geom_point(data = current_df, aes(x = lon, y = lat, alpha = I(alpha)), colour = \"gray30\", size = .2) +\r\n    coord_equal() +\r\n    theme(\r\n      panel.background = element_rect(fill = \"transparent\", colour = NA) # bg of the panel\r\n      , plot.background = element_rect(fill = \"transparent\", colour = NA) # bg of the plot\r\n      , panel.grid.major = element_blank() # get rid of major grid\r\n      , panel.grid.minor = element_blank() # get rid of minor grid\r\n      , legend.background = element_rect(fill = \"transparent\", colour = NA) # get rid of legend bg\r\n      , legend.box.background = element_rect(fill = \"transparent\", colour = NA) # get rid of legend panel bg\r\n    )\r\n  print(paste0(\"plotting frame \", frame))\r\n  print(p)\r\n}\r\nsaveGIF({\r\n  for (frame in 1:frames){\r\n    plotIteration(frame)\r\n  }\r\n}, interval = 0.03333, movie.name = \"output/maps/3_10_1000_more_lateral_offset.gif\")\r\n```"},"comment":{"url":"https://api.github.com/repos/yihui/animation/issues/comments/414934364","html_url":"https://github.com/yihui/animation/issues/91#issuecomment-414934364","issue_url":"https://api.github.com/repos/yihui/animation/issues/91","id":414934364,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDkzNDM2NA==","user":{"login":"larsedler","id":42141572,"node_id":"MDQ6VXNlcjQyMTQxNTcy","avatar_url":"https://avatars1.githubusercontent.com/u/42141572?v=4","gravatar_id":"","url":"https://api.github.com/users/larsedler","html_url":"https://github.com/larsedler","followers_url":"https://api.github.com/users/larsedler/followers","following_url":"https://api.github.com/users/larsedler/following{/other_user}","gists_url":"https://api.github.com/users/larsedler/gists{/gist_id}","starred_url":"https://api.github.com/users/larsedler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsedler/subscriptions","organizations_url":"https://api.github.com/users/larsedler/orgs","repos_url":"https://api.github.com/users/larsedler/repos","events_url":"https://api.github.com/users/larsedler/events{/privacy}","received_events_url":"https://api.github.com/users/larsedler/received_events","type":"User","site_admin":false},"created_at":"2018-08-22T07:10:41Z","updated_at":"2018-08-22T07:10:41Z","author_association":"NONE","body":"I had the same issue. Use\r\n```{r}\r\nggsave(p, filename = \"foo.png\",  bg = \"transparent\")\r\n```\r\nThis should give you the desired result."}}
{"actor":{"display_login":"larsedler"}}