2

I would like to use a custom column in gganimate title but couldn't read anywhere in docs how to do it.

Example using the code from their page:

library(gapminder)

ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.7, show.legend = FALSE) +
  scale_colour_manual(values = country_colors) +
  scale_size(range = c(2, 12)) +
  scale_x_log10() +
  facet_wrap(~continent) +
  # Here comes the gganimate specific bits
  labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
  transition_time(year) +
  ease_aes('linear')

I want 'GDP per capita' (Just a silly example I know) in title instead of year. I've tried replacing 8th line with:

labs(title = 'Gdp: {gdpPercap}', x = 'GDP per capita', y = 'life expectancy') +

No succcess so far

useRj
  • 1,232
  • 1
  • 9
  • 15
  • show your data please. You can try to use `transition_reveal()` with `{frame_along}` – Roman Nov 26 '18 at 10:58
  • data is gapminder. Anyone can get that dataframe. {frame_along} and how to choose the column? – useRj Nov 26 '18 at 14:35
  • Have you looked into this [clever, but hacky-ish approach](https://stackoverflow.com/a/53866108/9406040)? – Roman Dec 24 '18 at 22:21

0 Answers0