Hello everybody! My name is Simon and this is my first post here. Ive been working with R before in my studies with a focus on regressions, but im new to the topic of animation data in R. Im impressed how well and beautiful this works!
Right now I am working on a animated Bar-Race-Chart. I'm very happy with the result but there is one thing I cannot fix myself. Here is what i have so far.
I would like the numbers, displayed by geom_text(aes(y=new_infections1,label = Value_lbl, hjust=0),size = 8 )
be counted up/down day-to-day in a smooth way. Just like the bars, growing smooth.
I hope i can explain what i mean, otherwise you can see it in this video: https://i.gyazo.com/413434116ba9c97174166e8a1188de90.mp4
here is my code i use so far:
anim = ggplot(dec_intake_formatted, aes(rank, group = country))+
geom_tile(aes(y = new_infections1/2,
height = new_infections1,
width = 0.9), alpha = 0.8, color = NA) +
geom_text(aes(y = 0, label = paste(country, " ")), vjust = 0.2, hjust = 1, size = 7) +
geom_text(aes(y=new_infections1,label = Value_lbl, hjust=0),size = 8 ) +
coord_flip(clip = "off", expand = TRUE) +
scale_x_reverse() +
theme_minimal() +
theme(axis.line=element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
legend.position="none",
panel.background=element_blank(),
panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
panel.grid.major.x = element_line( size=.1, color="grey" ),
panel.grid.minor.x = element_line( size=.1, color="grey" ),
plot.title=element_text(size=25, hjust=0.5, face="bold", colour="red", vjust=-1),
plot.subtitle=element_text(size=18, hjust=0.5, face="italic", color="red"),
plot.caption =element_text(size=12, hjust=0.5, face="italic", color="red"),
plot.background=element_blank(),
plot.margin = margin(1,4, 1, 8, "cm")) +
transition_states(datum, transition_length = 4, state_length = 1) +
ease_aes('sine-in-out') +
labs(title = 'Neuinfektionen am: {closest_state}',
caption = "Data Source WHO/JHU")
my first idea was to find the "finer" data in "anim". but this doesnt really work.
I hope you can help me! thank you guys for your help in advance and stay healthy!