Question: Can I modify and save figures without regenerating each from scratch?

I want to generate a sequence of PNGs that I will then turn into an animation with ffmpeg. With matplotlib, I can do this roughly as below. Can I do similar things with GMT?

import matplotlib.pyplot as plt
plt.figure()
… Add a bunch of stuff to the figure …

for index in range(1000): # Create a sequence of images with numbers 0…1000
text_ptr = plt.text(x, y, f’{index}’)
plt.savefig(f’fig{index:03}.png’
text_ptr.remove() # Remove 'previous text

… create animation by using the resulting 1000 .png files

Hi Ian, welcome to the GMT universe.

I’m sure you found the movie module already. I’m not quite sure I understood your objective: You want to animate text superimposed on your static plot?

You could achieve something like this in classic mode: Generate the plot layer once and then all the frames with your text. Then bake them into your final frames. Be warned: classic mode is very powerful and has an equally steep learning curve.

If you just want to animate some text over a static plot a detour into your favourite post production software might be the easiest solution. Just animate it right in there.

Hi Ian, unfortunately the movie module has not been wrapped in PyGMT yet as it is nontrivial. For bash command line scripting and movie making you can see what can be done by visiting the GMT YouTube channel.