Creating Animation from multiple Images

Hi, I’m working on a project where I’ve to work with reflecting rays. I’ve written the code to trace the rays and reflection, but want to visualize the ray paths (just to quickly make sure that everything works well). I am using PyPlot.imshow inside a loop but it’s just showing me the last plot. Is there a way by which I can quickly create an animation and see the rays traveling.

Here’s my code (along with the output) to generate plots inside the loop

for sNum in raysCoords
    for ray in sNum
        Mod = zeros(size(velMod))
        for coord in ray
            Mod[coord[1], coord[2]] = 1
        end
        PyPlot.imshow(Mod)
        PyPlot.show()
    end
end

image

https://docs.juliaplots.org/latest/animations/

I don’t understand how I can modify my code to work like this.

Yeah the example is overcomplicated imho…

But it should just be this, more or less:

@gif for ray in snum
    mod = zeros(size(velMod))
    for coord in ray
        mod[coord[1], coord[2]] = 1
    end
    plot(mod)
end 

You will need to learn Plots.jl a little, and I don’t fully understand your code.

Try putting your PyPlot command inside a display() command.

Now I’m getting this output

PyObject <matplotlib.image.AxesImage object at 0x7fed3ac04a00>

PyObject <matplotlib.image.AxesImage object at 0x7fed3ac0ffd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3aae35b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ac29400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ac04f40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ac7b280>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ac7b070>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ac049d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ac39550>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ac04c70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ac29280>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83d250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83d520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83d7f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83dac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a86beb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a86b0a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a86b370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a86b640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a86b910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a862d00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83dd90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8621c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a862490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a862760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a862a30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a86bbe0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a862fd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83f2e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83f5b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83f880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83fb50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e0f40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e0130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e0400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e06d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e09a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9dcd90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a83fe20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9dc250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9dc520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9dc7f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9dcac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e0c70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9f60a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9f6370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9f6640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9f6910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9d0d00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9f6eb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9d01c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9d0490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9d0760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9d0a30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9f6be0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9d0fd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e7280>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e74c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e7760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e7ca0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2af40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2a130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2a400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2a6d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2a9a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab04d90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9e7fa0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab04250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab04520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab047f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab04ac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2ac70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2b0a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2b370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2b640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2b910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2dd00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2beb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2d1c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2d490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2d760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2da30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2bbe0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab2dfd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab792e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab795b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab79880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab79b50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab44f40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab44130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab44400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab446d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab449a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab65d90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab79e20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab65250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab65520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab657f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab65ac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab44c70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab670a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab67370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab67640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab67910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab47d00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab67eb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab471c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab47490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab47760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab47a30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab67be0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ab47fd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abf02e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abf05b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abf0880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abf0b50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbcf40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbc130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbc400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbc6d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbc9a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abefd90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abf0e20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abef250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abef520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abef7f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abefac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbcc70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abcc0a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abcc370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abcc640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abcc910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbdd00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abcceb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbd1c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbd490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbd760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbda30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abccbe0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3abbdfd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95c2e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95c5b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95c880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95cb50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96af40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96a130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96a400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96a6d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96a9a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95ad90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95ce20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95a250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95a520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95a7f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a95aac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96ac70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a94e0a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a94e370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a94e640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a94e910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96ed00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a94eeb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96e1c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96e490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96e760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96ea30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a94ebe0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a96efd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8072e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8075b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a807880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a807b50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a82bf40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a82b130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a82b400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a82b6d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a82b9a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a831d90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a807e20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a831250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a831520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8317f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a831ac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a82bc70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a81d0a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a81d370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a81d640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a81d910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a7fdd00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a81deb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a7fd1c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a7fd490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a7fd760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a7fda30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a81dbe0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a7fdfd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a32e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a35b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a3880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a3b50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a7f40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a7130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a7400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a76d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a79a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8b8d90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a3e20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8b8250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8b8520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8b87f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8b8ac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8a7c70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8950a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a895370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a895640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a895910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a884d00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a895eb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8841c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a884490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a884760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a884a30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a895be0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a884fd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8ec2e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8ec5b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8ec880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8ecb50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8f8f40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8f8130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8f8400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8f86d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8f89a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8efd90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8ece20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8ef250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8ef520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8ef7f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8efac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8f8c70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8d10a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8d1370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8d1640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8d1910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8c8ee0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8d1eb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8c81c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8c8460>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8c89d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8c8c70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8d1be0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a8c8c40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a99a2e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a99a5b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a99a880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a99ab50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9aff40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9af130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9af400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9af6d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9af9a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9b6d90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a99ae20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9b6250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9b6520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9b67f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9b6ac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9afc70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9940a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a994370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a994640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a994910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9a5d00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a994eb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9a51c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9a5490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9a5760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9a5a30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a994be0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a9a5fd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acc32e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acc35b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acc3880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acc3b50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acdaf40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acda130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acda400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acda6d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acda9a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ace5d30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acc3e20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ace5070>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ace53a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ace56d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ace5a00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acdac70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acf40a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acf4370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acf4640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acf4910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acd6d00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acf4eb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acd61c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acd6490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acd6760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acd6a30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acf4be0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acd6fd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acfa2e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acfa5b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acfa880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acfab50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad32f40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad32130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad32400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad326d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad329a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad1bd90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3acfae20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad1b250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad1b520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad1b7f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad1bac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad32c70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad060a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad06370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad06640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad06910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a23dd00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad06eb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a23d0a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a23d370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a23d640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a23d910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad06be0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a23dfd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a2492e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a2495b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a249880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a249b50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a255f40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a255130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a255400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a2556d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a2559a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a262d90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a249e20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a262250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a262520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a2627f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a262ac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a255c70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a26f0a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a26f370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a26f640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a26f910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae14d00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a26feb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae141c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae14490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae14760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae14a30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3a26fbe0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae14fd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae342e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae345b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae34880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae34b50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae0ef40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae0e130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae0e400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae0e6d0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae0e9a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae23d90>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae34e20>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae23250>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae23520>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae237f0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae23ac0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae0ec70>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae300a0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae30370>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae30640>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae30910>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad3dd00>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae30eb0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad3d1c0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad3d490>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad3d760>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad3da30>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ae30be0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad3dfd0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad732e0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad735b0>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad73880>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad73b50>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad45f40>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad45130>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad45400>
PyObject <matplotlib.image.AxesImage object at 0x7fed3ad456d0>

Please consider the environment before printing

This works in Julia 1.6.0 Win10:

using PyPlot

for i=1:30
    X = rand(20,20)
    sleep(0.1)
    display(PyPlot.imshow(X))
end

It might be better to have a separate loop to see the rays being updated in a plot window. And to have a dedicated loop to write an animated gif to disk, as gif generation might be too slow.

Plots.jl seems to be faster displaying the updates:

using Images, Plots; gr()

for i=1:30
    sleep(0.1)
    X = Gray.(rand(300,300))
    display(Plots.plot(X))
end
1 Like

I’m facing the same problem when I’m using imshow.

I also tried using heatmap and that works fine except the y axis is inverted. I can’t find a way to invert the y axis such that [0,0] of the matrix is top left instead of bottom left.

using Plots
for rec in shotCoords[1]
    Mod = zeros(Int, size(velMod))
    for coord in rec
        Mod[coord[1], coord[2]] = 1
    end
    sleep(0.1)
    display(heatmap(Mod))
end

You can use heatmap’s yflip argument:

using Plots
N = 100
Mod = zeros(N,N)
for i = 1:2N
	i <= N ?  (Mod[i,i÷2+1]=1) : (Mod[2N-i+1,i÷2]=1) 
    display(heatmap(Mod,legend=false, yflip=true))
end

rays_heatmap_yflip