jn_br
jn_br

Reputation: 99

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

Upvotes: 0

Views: 670

Answers (2)

August
August

Reputation: 12558

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.

Upvotes: 1

Bill
Bill

Reputation: 6086

What you show looks like multiple barplots or histograms (hist!() function or barplot!() function) with transparency allowing see-through overlap. Could you do this using barplot or hist! (depending on your data) instead of stairs!? If you want the barplots to be more uniform in outline, you could make the outline strokewidth thicker and the same strokecolor as the bars.

Upvotes: 0

Related Questions