Band filled by vertical gradient in Makie.jl

Looking at the recipe of the function density you could try something like this:

using CairoMakie
x = range(-2, 2, 100) |> collect
y = exp.(-x.^2)
f = Figure()
Axis(f[1, 1])
lines!(x, y, linewidth = 4, color = :black)
lowerv = Point2f.(x, zeros(length(x)))
upperv = Point2f.(x, y)
col = vcat(Float32[1-l[2] for l in lowerv], Float32[1-l[2] for l in upperv])
band!(lowerv, upperv, color=col, colormap = :grays)
f

1 Like