I want to animate a fill value transition between states. I have a 100x100 grid of geom_points that take values between 0 and 1. Essentially, the points stay in the same position at every point in time, but their fill value changes, which I want to animate. Here an excerpt on the data
head(strg)
Var1 Var2 const4 pred id
1 -1.0000000 -1 1 3.337224e-37 1
2 -0.9292929 -1 1 1.922538e-34 2
3 -0.8585859 -1 1 2.561529e-32 3
4 -0.7878788 -1 1 2.522569e-30 4
5 -0.7171717 -1 1 1.433660e-28 5
6 -0.6464646 -1 1 1.795601e-27 6
where const4 takes on the different states. And here the initial plot
ggplot(strg, aes(x = strg[,1], y = strg[,2])) + geom_point(aes(color = strg[,"pred"])) + scale_color_gradient("Predictions", low = "blue", high = "orange")
My questions are now
- How do I have to structure my data frame upon which the ggplot is build? I thought about having it repeat for all the states in const4.
- What function to use in gganimate to visualize the tranisition?