MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.39k stars 303 forks source link

Bug in Streamplot animation when initialized as 0. #3936

Open arturofburgos opened 3 months ago

arturofburgos commented 3 months ago

I was testing this case where I wanted to create an animation of a streamplot. I found a bug when the streamplot was initialized with 0. When zero_start is true the animation shows the bug where only the first frame is shown, when zero_star is false it does work normally.

using CairoMakie

zero_start = true

function v(x::Point2{T}, t) where T
    if t == 0 && zero_start
        Point2{T}(0, 0)
    else
        Point2{T}(x[2] * t, 4 * x[1])
    end
end

vt(t) = x -> v(x, t)

sf = Observable{Any}(vt(0.0))
title_str = Observable("t = 0.00")
sp = streamplot(sf, -2..2, -2..2;
    linewidth=2, colormap=:magma, axis=(;title=title_str))

record(sp, "output.mp4", LinRange(0, 20, 20); framerate=10) do t
    sf[] = vt(t)
    title_str[] = "t = $(round(t; sigdigits=2))"
end
asinghvi17 commented 3 months ago

To clarify, are the videos below similar to what you experienced? zero_start = true:

https://github.com/MakieOrg/Makie.jl/assets/32143268/e58d0090-6017-4fda-9a3f-ccb4b8a78931

zero_start = false:

https://github.com/MakieOrg/Makie.jl/assets/32143268/721c8505-229f-48ed-aea7-ecacad2f6ec1

arturofburgos commented 3 months ago

Yes, exactly.

asinghvi17 commented 3 months ago

With GLMakie and zero_start = true, I get this:

https://github.com/MakieOrg/Makie.jl/assets/32143268/0fb9aa3c-dcaa-45da-a6c7-ad24f4929cea

so it looks like this issue is only happening in CairoMakie. The flipping of the axis would seem to indicate some form of rendering issue...

arturofburgos commented 3 months ago

Yeah I would guess that. This is my first issue open. How is the procedure for someone to fix this bug?

jkrumbiegel commented 3 months ago

I would guess the streamlines produce some pattern of NaNs that crashes the line drawing function in CairoMakie. It's relatively complex to be more efficient, but also more bug prone.