juliamakie.jl

Fill region below stairs plot with a particular transparency using Makie.jl in Julia


I'd like to fill the region below a stairs!() plot (between the stairs and the x axis) in order to get something like the gray area in the image, but with a specific % transparency.

enter image description here


Solution

  • A somewhat hacky way (digs into the stair plot to get the graphed points):

    function stairpts(s)
        pts = s.plots[1].converted[1][]
        [p[1] for p in pts], [p[2] for p in pts]
    end
    
    s = stairs!(xs, ys, step=:post)
    
    xs′, ys′ = stairpts(s)
    band!(xs′, 0*ys′, ys′, color=(s.color, 0.25)) # 0.25 alpha
    

    Creating a recipe for this type of plot is probably better.