iT邦幫忙

1

R語言-視覺化-GIF圖 (GIF in r.studio)

  • 分享至 

  • twitterImage
  •  

廢話不多說,直接附上code
影片含有程式碼詳細解說,若有誤再煩請告知,謝謝/images/emoticon/emoticon25.gif

Yes

library(gapminder)
library(gganimate)
library(gifski)
library(dplyr)

data(gapminder)
gif <- gapminder %>%  
  ggplot(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() +
  # new
  labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
  transition_time(year) + #時間間隔,range = c(10L, 20L)
  ease_aes('linear') #呈現效果

animate(gif, duration = 5, fps = 20, 
        width = 500, height = 300)
#duration 動畫持續時間 fps每秒跳幾張
anim_save("D:\\output.gif")


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言