Earlier this week Mike Bostock tweeted a interesting looking contour plot with a link to edit the formula and manipulate the graphic using D3.js.
A live 2D function plot. Edit the function and reply with interesting images! https://t.co/joWfPgUAAU pic.twitter.com/XYhvJBavRM
— Mike Bostock (@mbostock) September 3, 2018 I decided I would attempt to recreate the image using ggplot2, and animate it using the new gganimate package.
Creating the data I started by creating a data frame with all the combinations of x and y on a grid between -10 and 10, in intervals of 0.
Recently I’ve been looking for an excuse to try out Thomas Lin Pedersen’s new grammar of animation, which is an extension of ggplot2 and a retooling of the existing gganmiate package. You can find the new package here.
Luckily for me, Rafael Irizarry provided the perfect inspiration:
Happy #MayFourth #rstats
— Rafael Irizarry (@rafalab) May 4, 2018 So in honor of Star Wars day, I decided to create Rafael’s TIE fighter GIF using the new gganimate.
If you haven’t seen it yet, there’s a great example of why it’s always important to visualize your data making its way around the Twitter-verse.
A great demonstration of why we need to plot the data and never trust statistics tables! https://t.co/JyUb57v0or pic.twitter.com/hsivGZdpZ1
— Taha Yasseri (@TahaYasseri) May 1, 2017 Despite looking very different, all of these datasets have the same summary statistics to two decimal places. You can download the datasets, get details about the project, and read the whole paper by Justin Matejka and George Fitzmaurice here.