# How to produce a waterfall plot in Julia?

**URL:** https://discourse.julialang.org/t/how-to-produce-a-waterfall-plot-in-julia/93441
**Category:** Visualization
**Tags:** question, plotting
**Created:** [January 24, 2023, 3:41am UTC](https://discourse.julialang.org/t/how-to-produce-a-waterfall-plot-in-julia/93441 "2023-01-24T03:41:45Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [January 24, 2023, 10:01am UTC](https://discourse.julialang.org/t/how-to-produce-a-waterfall-plot-in-julia/93441/3 "2023-01-24T10:01:03Z")

</div>

Here’s something I came up with using Makie:

```julia
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

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/a/2a43f3d91ae0223396ae57c52da88e0909e6ad57.png)

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

> [@fusion809](#):
>
> how does one produce a surface plot with just matrices (no function for finding z from x and y)?

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

---

_[View the full topic](https://discourse.julialang.org/t/how-to-produce-a-waterfall-plot-in-julia/93441)._
