Animate Graphs in R: Make Gorgeous Animated Plots with gganimate

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 82

  • @miam7401
    @miam7401 4 ปีที่แล้ว +16

    These are by far the best videos on R I have found! You make learning how to code in R very exciting. Thanks!

  • @Sarah-lf8im
    @Sarah-lf8im 3 ปีที่แล้ว +4

    This is so great! We really need more R youtubers like you in the world :)

  • @douglasaraujo9763
    @douglasaraujo9763 4 ปีที่แล้ว +10

    Such a great video. I saw this on reddit and immediately clicked here, since the other video was also very useful and pedagogic. So let me congratulate you this amazing content. Thanks so much!

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      That’s great to hear!-Glad you enjoyed the videos!

    • @teamsebago2
      @teamsebago2 3 ปีที่แล้ว

      Couldn’t agree more! Going to use this to make some amazing data analytics presentations

  • @danv8718
    @danv8718 ปีที่แล้ว

    This was a fantastic tutorial, but that file name with a blank space in the middle sent shivers down my spine!

  • @IarukaSkYouk
    @IarukaSkYouk ปีที่แล้ว

    You are an absolute master sir, every video you made is top-notch.

  • @hawkingswheelchair600
    @hawkingswheelchair600 3 ปีที่แล้ว

    That first graph is stunningly beautiful.

  • @GOATMENTATOR
    @GOATMENTATOR ปีที่แล้ว +1

    This was useful to me - thanks a lot!!

  • @marijnderijk1843
    @marijnderijk1843 3 ปีที่แล้ว

    You are a staight legend my man!! Thank you so much for the great videos, they help me a lot.

  • @Calumc12
    @Calumc12 4 ปีที่แล้ว +3

    I cant seem to render the animation, I have installed GIFSKI and loaded the package although im getting the error "Warning message:
    file_renderer failed to copy frames to the destination directory "

  • @RahulGupta-vw8jr
    @RahulGupta-vw8jr 4 ปีที่แล้ว +1

    Hey man, great video. Very useful, this is exactly what I have been looking for. Cheers

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      Glad it helped, thanks for watching!

  • @mfolozidlamini7347
    @mfolozidlamini7347 3 ปีที่แล้ว

    Very helpful and useful. I was stuck for about 20 hours working on transition and animated graph

  • @paulrefalo6791
    @paulrefalo6791 4 ปีที่แล้ว +8

    I really appreciate this video. I'm no beginner with R and ggplot2 but had never tackled animated gifs. Thank you! Excellent video and excellent content.

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      Glad to hear it! Be on the lookout for some more ggplot2 content in the near future!

  • @Master-of-None-88
    @Master-of-None-88 4 ปีที่แล้ว +1

    Beautiful! Thanks for sharing!

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      Thanks for watching!

  • @timeprint1117
    @timeprint1117 4 ปีที่แล้ว +1

    Exellent video, you deserve more recognition, subscribed

    • @dataslice
      @dataslice  4 ปีที่แล้ว +1

      Much appreciated!

  • @israeljesuslopez3833
    @israeljesuslopez3833 3 ปีที่แล้ว +1

    Hi, I got some data from a weather station I would like to plot. These are basic parameters (i.e. temp, pressure, wind speed,, dew point and heat index). I would like to plot these parameters in Y-axis and time on X-axis. However, the registers for time is awkward to me because I have the dates (22/02/2021) and times (04:00 a. m.). How can I transform these in one single column of time?

    • @dataslice
      @dataslice  3 ปีที่แล้ว +1

      You could use the lubridate package (which allows you to parse date times). Then you can use a combination of the built in functions and lubridate parsing functions to convert your columns into a 'date time object'. You might want to do something like dmy_hm(paste(, )). `Paste` will combine your date and time columns and `dmy_hm` parses a date time in that format. Here's the lubridate cheat sheet with more info evoldyn.gitlab.io/evomics-2018/ref-sheets/R_lubridate.pdf

  • @mikiallen7733
    @mikiallen7733 11 หลายเดือนก่อน

    hi sir , thanks for the effort , however how one can use the same package to generate such dynamic graphs in case of on-line (live) data polling case ? would you kindly provide an example to showcase such situation , thanks

  • @pablodeargentina
    @pablodeargentina ปีที่แล้ว

    Amazing work!

  • @moratzkleber8161
    @moratzkleber8161 3 ปีที่แล้ว

    Good work, much appreciated!

  • @cynthiamsun
    @cynthiamsun 3 ปีที่แล้ว +1

    I'm an amateur coder studying international relations, but your video made me so excited about R that I'm planning to use this for my capstone presentation!

    • @dataslice
      @dataslice  3 ปีที่แล้ว

      That's awesome -- good luck!

    • @cynthiamsun
      @cynthiamsun 3 ปีที่แล้ว

      @@dataslice Thank you for the inspiration!

  • @22bears
    @22bears 2 ปีที่แล้ว

    I have a problem, I can't see the GIF on my Plot window on RStudio?... the GIF won't get saved even tho I downloaded magick and gifski.
    Also, 200 pictures get saved on my project folder instead of the GIF itself… any idea how to fix this? Thanks!

  • @chrislaw42
    @chrislaw42 2 ปีที่แล้ว

    Love this!

  • @jihedncib1422
    @jihedncib1422 4 ปีที่แล้ว +1

    Your tutorials are really good! Subscribed.

  • @dvisno
    @dvisno 3 ปีที่แล้ว +4

    Amazing tutorial!!! Does it happen to anybody, that instead of appearing in the viewing (as an animation) or saved as .gif, it saves every frame as a single .png file?

  • @JanoAcosta-x6p
    @JanoAcosta-x6p 11 หลายเดือนก่อน

    Hi! How are you? I found the video very interesting and useful. I wanted to ask if there's a way to plot lines or curves that remain constant during the simulation. I wanted to use this tool to simulate a phase diagram and I would like to keep the demarcation curves fixed while simulating the trajectory. Is there a way to do this?

  • @cdvs100
    @cdvs100 4 ปีที่แล้ว

    How can I animate a matriz inside of a for cycle that it's updated step by step?

  • @jsbart96
    @jsbart96 2 ปีที่แล้ว

    Great vid, thanks :)

  • @amanprateek9340
    @amanprateek9340 4 ปีที่แล้ว

    Thanks for sharing such a great video. I am a beginner with R. Seeing this particular video really boosts my interests in the tool.
    Excellent content.

  • @agnelodearaujo7413
    @agnelodearaujo7413 2 ปีที่แล้ว

    Is it possible to pipe this to ffmpeg or something to make a video of the animations ?

  • @muhamadbayuprakoso6016
    @muhamadbayuprakoso6016 2 ปีที่แล้ว

    This is the best! I would like to ask a question, why I get this problem when I run the graph.animation "There were 50 or more warnings (use warnings() to see the first 50)" ? Thank you

  • @cryptoasgard8685
    @cryptoasgard8685 3 ปีที่แล้ว

    if it possible to animate a function f(x) e.g., over the range of values of x? searched a lot, but couldn't find any. Can u provide some reference?

  • @yunes7305
    @yunes7305 4 ปีที่แล้ว

    Don't stop, cheers 👍

  • @valerionetophdcandidate
    @valerionetophdcandidate 2 ปีที่แล้ว

    I have problem with "color=Genre" "Error in FUN(X[[i]], ...) : object 'Genre' not found". i tried to run without it and the color of the line was only one. I think I made a mistake in something. Could you show how to change colors of the lines?

  • @nuraziz1669
    @nuraziz1669 3 ปีที่แล้ว

    Great job mate~

  • @pigio87
    @pigio87 4 ปีที่แล้ว +1

    Cheers mate, my next presentation will be lit

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      Glad to hear it!

  • @babybopkidsrock5713
    @babybopkidsrock5713 ปีที่แล้ว

    Can animations be exported as movie or gif files?

  • @douglasdalen
    @douglasdalen 3 ปีที่แล้ว

    Great vid, but I got a little stuck... See I follow your lead all the way til you started animating your initial graph. I plotted the graph WITHOUT assigning it to variable "graph1" and it worked fine, then when I DID assign it to "graph1" I'd have it in my environment just like u did only except my plot just wouldn't show up. Consequently my animation failed on me too. Nothing to see over at the Viewer window. I tried fiddling around with it a bit but with no luck. I also adhered to your advice regarding gifski but that wouldn't solve my problem either. Any ideas on how to fix it?
    Edit: Tried starting fresh and assigned the super simple ggplot graph early on like you did. The plot won't show at all, so I'm guessing that's where the problem is (from graph1 = ... to geom_point() ). When I inspect "graph1" it shows the right data and everything.

    • @dataslice
      @dataslice  3 ปีที่แล้ว

      Just to clarify, you tried saving your graph into the “graph1” variable? Did you try running the code “graph1” to get it to output to the viewer?

    • @douglasdalen
      @douglasdalen 3 ปีที่แล้ว

      @@dataslice Just gave it another shot with the code below (same as yesterday, only now explicitly telling R to plot the graph):
      Graph1 %
      ggplot(aes(x = gdpPercap, y = lifeExp, color = continent, size = pop))+
      geom_point()
      plot(Graph1)
      So this worked for me, not sure why I had to be explicit when you didn't.
      Imma try and fill out the rest and will update if it works out!

    • @douglasdalen
      @douglasdalen 3 ปีที่แล้ว +1

      Finally got everything to work. I made a few changes (like facet wrapping by continent) and omitted some of your code (like the font family). Here's my end result:
      # Import required libraries
      library(gganimate)
      library(ggplot2)
      library(dplyr)
      library(gapminder)
      library(ggthemes)
      library(gifski)
      library(plotly)
      gapminder
      names(gapminder)
      # Graph1: Transitioning through time
      Graph1 %
      ggplot(aes(x = gdpPercap,
      y = lifeExp,
      color = continent,
      size = pop))+
      geom_point(alpha = 0.7,
      stroke = 0)+
      theme_fivethirtyeight()+
      scale_size(range = c(2, 12),
      guide = "none")+
      scale_x_log10()+
      labs(title = "Life Expectancy vs GDP Per Capita by Country",
      x = "GDP per Capita)",
      y = "Life Expectancy (years)",
      color = "Continent",
      caption = "Source: Gapminder")+
      theme(axis.title = element_text(),
      legend.text = element_text(size = 10))+
      scale_color_brewer(palette = "Set2")
      # Explicitly plot the graph.
      Graph1
      # Animate the graph
      AniGraph

    • @parkerfrancisgauthier7360
      @parkerfrancisgauthier7360 2 ปีที่แล้ว

      Very helpful thread :)

  • @MarcelloNesca
    @MarcelloNesca 4 ปีที่แล้ว

    i really enjoyed your reasoning on separating your ggplot with your gganimate. If i may request while you are on a visualization high, package sf for geospatial analysis please.

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      Great suggestion -- I'll check it out! Thanks for watching

  • @mashtonish
    @mashtonish 4 ปีที่แล้ว

    finally, I can do my own "thing over ### time" youtube channel with the second example ;)

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      Absolutely! Thanks for watching!

  • @chipweir9731
    @chipweir9731 3 ปีที่แล้ว

    Awesome video, I'm very greatful for your content! I was wondering, when my animated graph rendered, the output had the x-axis values and the x-axis label overlapping. Any idea how to fix that? Thanks!

    • @dataslice
      @dataslice  3 ปีที่แล้ว +1

      Yep, one fix would be to rotate the labels on the x-axis. Try adding `+ theme(axis.text.x = element_text(angle = 90))` to to your ggplot graph. 90 is the degrees it's rotated so you can play with the number

    • @chipweir9731
      @chipweir9731 3 ปีที่แล้ว

      @@dataslice Hmm, I got the x-axis labels to rotate but they still overlapped with the x-axis title in the outputted gif. I need to put the x-axis title lower than the x-axis labels so that they're both readable. What're your thoughts? I wish I could just attach the gif so you could see exactly what I'm talking about. Thanks for the help!

  • @bisyrim1030
    @bisyrim1030 ปีที่แล้ว

    Hi there, u didn't mention your set2 palette colors so I just make my own palette

  • @suganyaragunath9348
    @suganyaragunath9348 4 ปีที่แล้ว

    This is just awesome.... Great video... Keep going...

  • @michielvermeulen6485
    @michielvermeulen6485 4 ปีที่แล้ว

    How do you get RStudio to look like dark mode?

    • @dataslice
      @dataslice  4 ปีที่แล้ว +1

      You just need to go to your RStudio preferences > Appearance > Editor Theme. Mine is set to 'Dracula'

  • @JeewanthaBandara
    @JeewanthaBandara 3 ปีที่แล้ว

    This is an outstanding tutorial!!!

  • @jamesglover494
    @jamesglover494 4 ปีที่แล้ว

    Great video and thanks for providing the github link, where did you get the csv file for vgsales and googleplaystore?

    • @dataslice
      @dataslice  4 ปีที่แล้ว +1

      No problem, thanks for watching! Both of the datasets are from Kaggle, and I just updated the description with their links

  • @crocodile2099
    @crocodile2099 4 ปีที่แล้ว +2

    legend

  • @carlosm.6348
    @carlosm.6348 ปีที่แล้ว

    Not sure if you still respond but I never understood the difference between using = and ->

    • @dataslice
      @dataslice  ปีที่แล้ว

      Great question
      In most cases (when you’re just assigning a value to a variable), they are the same
      There are some cases, like when using = or

  • @brazilfootball
    @brazilfootball 2 ปีที่แล้ว

    I also needed to install package "png" (install.packages("png")) and restart R to get it to work

  • @rogerwilcoshirley2270
    @rogerwilcoshirley2270 4 ปีที่แล้ว

    Wow thats for me - the fantastical frenetic bangles and baubles to adorn my vacuous presentation. Admittedly it can be quite the venue for showmanship or distracting from that annoying litany of ohs umms and interminable throat clearings if not that big pimple on the tip of the nose ;-). Seriously, thanks for the intro to this in R, wasn't previously aware just in Python, i'll be programming your examples, love learning new hands on skills as in yesss i can do R animated graphics 👍

  • @shuvhamdigitalacademy3228
    @shuvhamdigitalacademy3228 3 ปีที่แล้ว

    Brother which book do you read for this great plots? Love from Chapra, West Bengal, India.❤️

    • @dataslice
      @dataslice  3 ปีที่แล้ว +1

      I don't follow a specific book -- mostly just reading blog posts online, but the 'R for data science' online book is very helpful!

    • @shuvhamdigitalacademy3228
      @shuvhamdigitalacademy3228 3 ปีที่แล้ว

      @@dataslice Thank you are Love and Support.

  • @MichiganWater
    @MichiganWater 4 ปีที่แล้ว

    Nice

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      Thanks for watching!

  • @willTryAgainTmrw
    @willTryAgainTmrw 4 ปีที่แล้ว

    This video reminded me of beautiful R days. Now I am in python world, where you have to just grind to get a simple graph.
    Anyone knows a way to easily switch to R in a cell in jupyter? I know about R magic, but what I mean is we could just switch to R in one cell, use the variable which is already in memory as pandas DF, plot something using gg world, and then back to python in next cell. I expected things would have got better because of pyarrow, but doesnt seem so.

    • @dataslice
      @dataslice  4 ปีที่แล้ว

      That would be nice but unfortunately I don’t think it can be done!

    • @vineetsansi
      @vineetsansi 4 ปีที่แล้ว +1

      checkout package siuba in python that enables you to use piping, dplyr, i guess ggplot (not sure) as well to use it within python. Search TH-cam channel by name - Michael Chow. I think he is the one who has developed it as well.

  • @vineetsansi
    @vineetsansi 4 ปีที่แล้ว

    fabulous content, its really helpful for person like me who is just starting in R after python. Thanks for sharing. And to make it lines lead by relevant names one can add below code which can also be modified to lead numbers.
    directlabels::geom_dl(aes(label = Genre), method = list("last.points"))

    • @dataslice
      @dataslice  4 ปีที่แล้ว +1

      Great suggestion! Thanks for sharing

  • @stephenwilliams7494
    @stephenwilliams7494 ปีที่แล้ว

    13.04.2023 interesting BUT this is B.S....LINE 11 (graph1) is a PROBLEM....

  • @nnicola55555
    @nnicola55555 3 ปีที่แล้ว

    Great video, thank you! How would you recommend graphing a matrix with the 50 states? Please see below for an example of how the data is organized.
    State CA CT MA
    CA NA 30 50
    CT 50 NA 100
    MA 20 50 NA