Load GIF files into plot


I have results of a simulation saved as GIF files on my disk and I want to use a suitable plotting library to load and plot them with the x, y axes having specific values, the exported image will also be a GIF file.
So far, I tried loading the file with FileIO and plotting in Plots, PyPlot, Makie but neither of them accepts a GIF file for plotting or I was unable to see a result.

Is there a library or a working example for what I’m trying to do?


For the first part of your question, loading static gifs and plotting on them:

using FileIO, Plots; gr(dpi=300)
file = "moonsurface.gif"
pgif = load(file)
heatmap(pgif, legend=false)
plot!(x -> rand(1200:1400) + rand(1:40)*sin(x/100), c=:red, widen=false)
title!("Houston, we have a problem")

1 Like

Hmm now that’s interesting, I remember trying this before posting the question.
Running your code gave me the same error as before.

ERROR: Cannot convert Array{RGB{FixedPointNumbers.N0f8}, 3} to series data for plotting

Is something wrong with my GIF file?

FWIW, the gif file I used, loaded as:
Array{RGB{N0f8},2} with eltype RGB{FixedPointNumbers.N0f8}

Looks a bit like you have an animated gif that loads as a 3D array of pixels? Maybe it’s not animated but it still reads that way, you could try reshaping so the third singleton dimension goes away, or just index into the first dimension like img = gifdata[:, :, 1]/