gganimate

How to save frames of gif created using gganimate package

拈花ヽ惹草 提交于 2020-04-11 04:57:07
问题 I will use the gapminder data as an example. Let's say I create this animation: library(gapminder) library(ggplot2) theme_set(theme_bw()) p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year)) + geom_point() + scale_x_log10() library(gganimate) gganimate(p) gganimate(p, "output.gif") Now, I want to have access to the individual images (frames) that constitute the gif. Is there a way to do this in gganimate or do I need to use the animation package? 回答1:

Animated sorted bar chart: problem with overlapping bars

冷暖自知 提交于 2020-01-31 05:34:26
问题 I created an animated bar chart which displays the scored goals by some players. Below the whole code is displayed how I came to the output. The animation works as wished. However, bars with the same value overlap. I would like to prevent the bars from overlapping. The best case would be for the player who scored first to be displayed above other players at the same rank. The order of players who scored equally at the beginning of the animation does not matter. library(tidyverse) library

Problem with many (>50) states in gganimate

北城以北 提交于 2020-01-21 11:14:06
问题 I'm trying to create a GIF using gganimate for a data set covering 90 years, i.e. I want to have a GIF running through 90 states/years. However, it seems like gganimate is only able to deal with less than 50 states. So here's an example: library(tidyverse) # devtools::install_github('thomasp85/gganimate') library(gganimate) df = expand.grid( x = 1, y = c(2,3), year = 1670:1760) %>% mutate( z = 0.03* year, u = .2 * year) this all works fine for 49 years: ggplot(data=df %>% filter(., year %in%

gganimate stacked bar chart over time

安稳与你 提交于 2020-01-16 14:10:12
问题 I am trying to animate a stacked bar chart over time. In particular, I would like each stack to first build up in a given year and then transition to the next year. Also, I would like to make sure the past bars are visible. The following code plots each bar at once and transitions to the next year while making the previous years invisible. Is there a way to solve this issue? library(tidyr) library(ggplot2) library(gganimate) library(dplyr) df <- data.frame(stringsAsFactors=FALSE, Year = c(

gganimate: Combining transition_layers and geom_smooth

两盒软妹~` 提交于 2020-01-05 08:34:08
问题 How do I combine geom_smooth(method = "lm) function with gganimate()'s transition_layers, so that, as the individual bars drift/grow upwards, the linear line of geom_smooth appears, like so: Example of desired appearance of geom_smooth line The only difference is that in my case, instead of the points, the bars would drift upwards as the line appears. The bars current work well, appearing by drifting upwards, made possible by using the transition_layers function of gganimate. However, I can't

custom column to frame title in gganimate

怎甘沉沦 提交于 2020-01-05 05:47:13
问题 I would like to use a custom column in gganimate title but couldn't read anywhere in docs how to do it. Example using the code from their page: library(gapminder) ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) + geom_point(alpha = 0.7, show.legend = FALSE) + scale_colour_manual(values = country_colors) + scale_size(range = c(2, 12)) + scale_x_log10() + facet_wrap(~continent) + # Here comes the gganimate specific bits labs(title = 'Year: {frame_time}', x = 'GDP per

Keep points in gganimate

本秂侑毒 提交于 2020-01-04 05:05:45
问题 I would like to document the progress in a test situation using gganimate: I have come so far: library(tidyverse) library(gganimate) data <- tribble(~user, ~agree, ~accord, ~messung, "1", .8, .9, 1, "2",.7, .8, 1, "3", .6, .9, 1) data2 <- tribble(~user, ~agree2, ~accord2, ~messung2, "1", .4, .7, 2, "2", .5, .9, 2, "3", .9, .9, 2) data%>% left_join(data2)%>% mutate(user = as.numeric(user))%>% ggplot(aes(x = accord, y = agree))+ geom_point(aes(fill = "grey"), color = "grey", size = 2)+ geom

Using a gtable object with gganimate

醉酒当歌 提交于 2020-01-03 19:15:59
问题 I'm producing a gif with gganimate , and I'd like to make some tweaks to the plot format that can only be accomplished by converting a ggplot object to a gtable . For instance, I'd like to change the position of the plot title so that it always appears in the far left corner of the plot. Here's an example of what the plot tweak would look like: library(ggplot2) library(gganimate) library(dplyr) # Helper function to position plot title all the way to left of plot align_titles_left <- function

Including images on axis label in an animated ggplot2

浪子不回头ぞ 提交于 2020-01-01 05:42:12
问题 I created an animated bar plot displaying goals scored by players (fictional). Please see the reproduced data for the example: df <- data.frame(Player = rep(c("Aguero", "Salah", "Aubameyang", "Kane"), 6), Team = rep(c("ManCity", "Liverpool", "Arsenal", "Tottenham"), 6), Gameday = c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6), Goals = c(0,1,2,0,1,1,3,1,2,1,3,2,2,2,4,3,3,2,4,5,5,3,5,6), stringsAsFactors = F) Following animated bar plot are created by the code below. # loading required

Display different time elements at different speeds in gganimate

拜拜、爱过 提交于 2019-12-29 02:00:51
问题 Using the code from this answer, How to make dots in gganimate appear and not transition, as a MWE, say we have this gganimate: library(ggplot2) library(gganimate) a <- ggplot(airquality, aes(Day, Temp, group = interaction(Month, Day))) + geom_point(color = 'red', size = 1) + transition_time(Month) + shadow_mark(colour = 'black', size = 0.75) + enter_fade() animate(a, nframes = 100) or animate(a, fps=5) Is it possible to control the speed of each Month (time element)? For example, display