I have a simple bar chart. How can I make the bars appear sequentially? In other words, the first bar should appear. The second bar should appear (and the first one stays in the place). Then the third bar should appear (and the first two should stay in place).
Say I have this MWE:
library(ggplot2)
library(gganimate)
csv <- "fruit, value Apple, 60 Orange, 51 Watermelon, 50"
data <- read.csv(text=csv, header=TRUE)
ggplot(data, aes(fruit, value)) +
geom_bar(stat='identity') +
transition_reveal(fruit)
This does not work. What should I do?
You can add a column of numbers that gives the order they should appear:
data$fruit_order = 1:3
ggplot(data, aes(fruit, value)) +
geom_bar(stat='identity') +
transition_reveal(fruit_order)