Gganimate

gganatogram and gganimate

Today I wanted to see if I could create a slideshow of pictures from the gganatogram package. I wanted to combine them with the gganimate package, but I have not figured out how to get that to work. (In particular, the gganatogram() function seems to return a different list layout than ggplot objects.) library(gganatogram) ## Loading required package: ggpolypath ## Loading required package: ggplot2 library(gganimate) library(profvis) N <- 25 # number of cell samples num_cell_parts <- nrow(cell_key$cell) # randomly select a random number of cell parts part_picker <- sample(1:num_cell_parts, sample(1:num_cell_parts, 1)) cell_num <- rep(1, length(part_picker)) this_cell <- cell_key[['cell']][part_picker, ] cell_samples <- cbind(this_cell, cell_num) for(j in 2:N){ part_picker <- sample(1:num_cell_parts, sample(1:num_cell_parts, 1)) cell_num <- rep(j, length(part_picker)) this_cell <- cbind( cell_key[['cell']][part_picker, ], cell_num) cell_samples <- rbind(cell_samples, this_cell) # figure_list[j] <- gganatogram(data = this_cell, # outline = FALSE, fillOutline='steelblue', organism="cell", fill="colour") + # theme_void() + # coord_fixed() png(filename = paste0(j, ".

My First gganimate Plot

Today I finally read a tutorial on gganimate, and here I will build my first example. My hope is to eventually simulate traversal on a directed graph. library(tidyverse) library(gganimate) Create Node Data For this example, I will have 3 nodes (located at 3 vertices of a triangle), 100 dots distributed among the nodes, and a new placement over 21 states in time. N <- 100 # number of dots T <- 20 # number of iterations node_names <- c("Node 1", "Node 2", "Node 3") iter <- rep(0, N) node <- rep("Node 1", N) x <- 10 + rnorm(N, 0, 2) y <- 20 + rnorm(N, 0, 2) states <- data.