How to produce a waterfall plot in Julia?

Here’s something I came up with using Makie:

using CairoMakie

xi = -15:0.1:15
t = 0:30
u1data = [exp(-(x-0.5*(t-15))^2) for x in xi, t in t]

fig = Figure()
ax = Axis3(fig[1,1];
    azimuth=-1.46, elevation=1,
    xticks=-15:5:15, zticks=0:2,
    limits=(nothing, nothing, (0,2)),
    xgridvisible=false, ygridvisible=false, zgridvisible=false,
    (Symbol.([:x, :y, :z], "spinecolor_", [2 3]) .=> :transparent)...,
    xlabel=L"\xi", ylabel=L"t", zlabel=L"|u|")

for (tval, z) in Iterators.reverse(zip(t, eachcol(u1data)))
    tvals = fill(tval, length(xi))
    band!(Point3.(xi, tvals, 0), Point3.(xi, tvals, z), color=:white)
    lines!(xi, tvals, z, color=:black)
end

fig

(Use GLMakie or WGLMakie instead of CairoMakie for interactivity.)

With Makie you can do surface(xi, t, u1data) where xi and t are vectors and u1data is a matrix.

6 Likes