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
— 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.