Real time plotting with Gadfly (Vehicle Trajectory Plotting)

Hello,

I would like to plot vehicle trajectory on a cartesian coordinate system in near-real time from the data that is coming from a datastream. Is it possible to do this in Gadfly.

My requirement is to push latest observation to the plot and make the plot update itself. I am looking for something similar what OnlineStats.jl does but I would like update the raw observations.

What would be the best plotting library for this purpose.

Thanks in advance.

You can do it with GLMakie, for example:

using GLMakie
GLMakie.activate!()

f = Figure()

data = Observable([0f0, 1f0])

ax, lin = lines(f[1, 1], data)

running = Observable(false)

b = Button(f[2, 1],
    label = @lift($running ? "Stop stream" : "Start stream"),
    tellwidth = false
)

on(b.clicks) do c
    running[] =! running[]
    if running[]
        @async while running[]
            push!(data[], data[][end] + randn())
            notify(data)
            autolimits!(ax)
            sleep(1/60)
        end
    end
end

f
3 Likes

Thank you the response. I will definitely look into it.

One more question, Lets say, I let the code run indefinitely, push the data indefinitely, will I encounter a memory problem? How does makie handle these issues. Do you have any knowledge about it? Does it summarize or smoothe the old data to keep up?

Again thank you for the nice example.

Yes of course, you can’t indefinitely push data into a vector. But you could just as well put some kind of online stats function in between, so that you limit the amount of data you show. That’s not really something that Makie is concerned with, it just shows the data.

1 Like

Great idea. Thank you!