Search code examples
ranimationggplot2gganimate

gganimate renders pixelated in windows 10


I must render some animations using gganimate but the images are not good looking. They lack definition and borders are pixelated. Is there any way of getting better results in windows 10?

My code is:

library(gapminder)
library(ggplot2)
library(gganimate)
Cairo(600, 600, file="plot.png", type="png", bg="white")
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')

What I get is this:

enter image description here


Solution

  • You can modify the default resolution with options()

    options(gganimate.dev_args = list(width = 5, height = 7, units = 'in', res=320))