Welcome to the forum @CM1 !
It’s probably slower since the combined plot has to be recreated every step of the animation, but this worked for me:
using Plots
N = 200
u1 = 20*rand(3, N)
u2 = 15*ones(3, N)
plt1 = plot3d(
1,
xlim = (-30, 30),
ylim = (-30, 30),
zlim = (0, 60),
title = ["Some trajectory"],
legend = false,
marker = 2,
)
plt2 = plot3d(
1,
xlim = (-30, 30),
ylim = (-30, 30),
zlim = (0, 60),
title = ["Other trajectory"],
legend = false,
marker = 2,
)
@gif for i in range(1, size(u1, 2))
push!(plt1, u1[:, i]...)
push!(plt2, u2[:, i]...)
plot(plt1, plt2)
end every 10
The docstring of plot
mentions this about extracting subplots, but I couldn’t get it to work in the intended way (creating a new plot seems to remove the previously drawn points):
help?> plot
...
Extract a subplot from an existing plot.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> p1, p2 = plot(1:2), plot(10:20)
julia> pl = plot(p1, p2) # plot containing 2 subplots
julia> plot(pl.subplots[1]) # extract 1st subplot as a standalone plot
julia> plot(pl.subplots[2]) # extract 2nd subplot as a standalone plot