1

我想在 gganimate 标题中使用自定义列,但无法在文档中的任何地方阅读如何做到这一点。

使用他们页面中的代码的示例:

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')

我想要标题中的“人均 GDP”(我知道的只是一个愚蠢的例子)而不是年份。我尝试将第 8 行替换为:

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

至今没有成功

4

0 回答 0