Advertisement
jorandradefig

script.R

Jun 6th, 2021
1,284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.04 KB | None | 0 0
  1. #======
  2. #Author: JA
  3. #Date: 6/6/21
  4. #======
  5.  
  6. #0
  7.  
  8. getwd()
  9.  
  10. pacman::p_load(
  11.   tidyverse,
  12.   plotly,
  13.   gganimate,
  14.   gifski,
  15.   devtools
  16. )
  17.  
  18. devtools::install_github("thomasp85/tweenr")
  19. devtools::install_github("thomasp85/transformr")
  20.  
  21. #ffmpeg
  22.  
  23. #1
  24.  
  25. temperaturas <- read_csv("temperaturas_globales.csv")
  26.  
  27. #2
  28.  
  29. #3
  30.  
  31. plot <- ggplot(temperaturas,aes(x=year,y=value)) +
  32.   geom_line() +
  33.   geom_point(
  34.     aes(fill=value),
  35.     size=5,
  36.     shape=21
  37.   ) +
  38.   scale_x_continuous(
  39.     limits=c(1880,2017)
  40.   ) +
  41.   scale_y_continuous(
  42.     limits=c(-0.5,1)
  43.   ) +
  44.   scale_fill_distiller(
  45.     palette="RdYlBu",
  46.     limits=c(-1,1)
  47.   )
  48.  
  49.  
  50.  
  51. plotReveal <-  plot + transition_reveal(
  52.     id=1,
  53.     along=year
  54.   )
  55.  
  56. plotTime <-  plot + transition_time(
  57.     year
  58.   )
  59.  
  60.  
  61. animate(
  62.   plotReveal,
  63.   width=600,
  64.   height=800,
  65.   fps=24,
  66.   renderer=ffmpeg_renderer()
  67. )
  68.  
  69. anim_save("temperaturas_reveal.mp4")
  70.  
  71. animate(
  72.   plotTime,
  73.   width=600,
  74.   height=800,
  75.   fps=24,
  76.   renderer=gifski_renderer()
  77. )
  78.  
  79. anim_save("temperaturas_time.gif")
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement