Skip to content

Instantly share code, notes, and snippets.

@thomasp85
Created June 6, 2018 19:05
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasp85/05169ad44ddcc8ed56da6ff7bf7fbe36 to your computer and use it in GitHub Desktop.
Save thomasp85/05169ad44ddcc8ed56da6ff7bf7fbe36 to your computer and use it in GitHub Desktop.
Gapminder example with gganimate
library(gapminder)
library(ggplot2)
library(gganimate)
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
geom_point(alpha = 0.7) +
scale_colour_manual(values = country_colors) +
scale_size(range = c(2, 12)) +
scale_x_log10() +
facet_wrap(~continent) +
theme(legend.position = 'none') +
labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
transition_time(year) +
ease_aes('linear')
animate(p, 100, 10)
@thomasp85
Copy link
Author

gganimate_birth12

@omarbenites
Copy link

Hi Thomas, this vis looks cool. However, I have a problem running the script. Two functions are not properly loaded
`

  • Error: could not find function "transition_time"
  • Error could not find function "animate"
    `

@EricKrg
Copy link

EricKrg commented Jun 8, 2018

Hi Thomas , i also really would like to use this but i having the same issue as omarbenites.

@ginolhac
Copy link

ginolhac commented Jun 8, 2018

you need the development version, did you install it with

devtools::install_github("thomasp85/gganimate") ?

transition_time was pushed very recently

@ginolhac
Copy link

ginolhac commented Jun 8, 2018

but as I get start_pause error using transition_time(), I added

start_pause <- 0
end_pause <- 0

before the ggplot() call. Shouldn't these variables be part of the transition_time() function instead of globals?

setting them to 0 seems to mimic your settings

gap_facets

@lmccully10
Copy link

Hi Thomas, this vis looks cool. However, I have a problem running the script. Two functions are not properly loaded
`

  • Error: could not find function "transition_time"
  • Error could not find function "animate"
    `

Did anyone ever figure this out? I'm having the same error and have devtools installed.

@thomasp85
Copy link
Author

do you have gganimate installed from CRAN?

@lmccully10
Copy link

do you have gganimate installed from CRAN?

I downloaded it from CRAN, then saw that you needed devtools to be able to use transition_time(). So I was finally able to install devtools to install directly from github but now getting "Permission Denied" and failure to install "gganimate" from GitHub.

@thomasp85
Copy link
Author

You don’t need devtools. Just the regular cran install. This is a super old conversation so don’t expect the recommendations given here to be current🙂

@lmccully10
Copy link

Huh odd, because I installed it originally through CRAN, but now when I call on the library it gives me:
"Error: package or namespace load failed for ‘gganimate’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘progress’
In addition: Warning message:
package ‘gganimate’ was built under R version 3.4.4 "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment