Is there a way to push additional datapoints to a plot when using time objects? The code below throws an error. Am I doing something wrong?
using Plots
using Dates
x = [now(), now() + Second(1)]
p = plot(Time.(x), 1:2)
push!(p, Time(now()), 2)
MethodError: no method matching push!(::Plots.Plot{Plots.GRBackend}, ::Time)
You probably want plot!(p, Time(now()), 2)
That seems to add new plot series when I try it?
Yes plot!
will add a new series to an existing figure, as Plots redraws the figure if you want to change things - there’s no real updating of existing Plots. You might want to look at Makie.jl if you really need this, alternatively you can do
plot!(p, Time(now()), 2, color = 1, label = "")
to redraw the figure with your additional points in another series with the same color and no additional label.
Makie looks super interesting. Thanks!
I was hoping to use the push! function kind of like this guy does
https://stackoverflow.com/questions/57827245/julia-plotting-push-adds-to-wrong-line