gganimate 在 windows 10 中呈现像素化

gganimate renders pixelated in windows 10

我必须使用 gganimate 渲染一些动画,但图像不好看。它们缺乏清晰度,边界像素化。有什么方法可以在 windows 10 中获得更好的结果?

我的代码是:

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

我得到的是:

您可以使用options()修改默认分辨率

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