I have been working on a project of visualising how a grid transforms to another one by applying some function. Here is an example:
The work is heavily inspired in this question . What I wanted to do next is, using matplotlib, create some animation that smoothly turns the original grid (labeled "identity" in the image above) into the final grid (labeled "example"). However, I have very little knowledge of the matplotlib library and its uses to animations. Can someone point to good resources or write a "skeleton", i.e. synthetic, code of how to proceed?
I have been able to animate more simple things with matplotlib, like the graph of a function. However, in this example I have to somehow keep the information about, for instance, the color of each line while animating. Here is the code for the update/animate function of matplotlib's animation class:
def update(frame):
for i, line in enumerate(lines):
p = i / (len(lines) - 1) # Normalize to 0-1.
# Transpose the list of points for passing to plot.
xs, ys = zip(*line)
x = [frame*x for x in xs]
y = [frame * y for y in ys]
# Get the line color from the colormap.
plt.plot(x, y, color=colormap(p))
However, the screen fills up with lines (which may be easy to fix since I just have to clean the screen after each frame (?)) and the result is not what I expected.
Thank you in advance.