데이터 시각화
움직이는 그래프를 만들어보자(gganimation)
r-code-for-data-analysis
2023. 5. 29. 10:02
gganimation이란 패키지를 이용하면 움직이는 그래프를 만들어볼 수 있다.
1. 결과 보기
2. 코드 분석
library(gganimate)
p <- ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
# Here comes the gganimate code
transition_states(
gear,
transition_length = 2,
state_length = 1
) +
enter_fade() +
exit_shrink() +
ease_aes('sine-in-out')
anim_save("d:/R/gif/gganima.gif", p)
library(gifski)
png_files <- list.files("d:/R/gif/", pattern = ".*png$", full.names = TRUE)
gifski(png_files, gif_file = "d:/R/gif/animation.gif", width = 800, height = 600, delay = 1)
728x90
반응형