Gif Animation Problem ggplot2

Hello there, I wanted to animate my barplot but when I try to do so I always get the bars 'truncated' in the animation. This is because the png images show truncated bars and it is not due to the gif "compiler".
The data comes from this website --> https://www.kaggle.com/gregorut/videogamesales

Could you help me with this? Thank you!

library(ggplot2)
library(dplyr)
library(gganimate)
library(gifski)

vg = read.csv("yourpath/vgsales.csv")
vg$Year = as.numeric(vg$Year) #transform to numeric
vg = vg[!is.na(vg$Year),] #filter out NA rows
vg_3 = vg[vg$Publisher=='Nintendo',]  #account only for Nintendo

#create an animation barplot
theme_set(
  theme_bw() + 
    theme(legend.position = "top")
  )

myplot = ggplot(vg_3, aes(x=Genre, y=Global_Sales, size = Global_Sales, color = Genre)) +
    geom_point(alpha=0.5)+
    scale_size(range = c(0.2, 11)) +
   labs(title = 'Year: {frame_time}', x = 'Publishers', y = 'Sales') +
   transition_time(Year) +
   ease_aes('linear')

animate(myplot, duration = 9, fps = 25, width = 900, height = 700, renderer = gifski_renderer())
anim_save("output.gif")

Hey,

I fixed some lines,

vg$Year = as.numeric(vg$Year) #transform to numeric
vg_2 = vg[!is.na(vg$Year),] #filter out NA rows
vg_3 = vg_2[vg_2$Publisher=='Nintendo',] #account only for Nintendo

the code missed vg_2
And I successfully run the code until the end.

Sorry I forgot to update it. The real one is as you say. The problem is not the filtering but the gif :slight_smile:

I just updated it to the real one!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.