-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathlinesfill.jl
39 lines (37 loc) · 1.12 KB
/
linesfill.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
linesfill(xs, ys; lower, upper, attributes...)
Line plot with a shaded area between `lower` and `upper`. If `lower` and `upper`
are not given, shaded area is between `0` and `ys`.
## Attributes
$(ATTRIBUTES)
"""
@recipe(LinesFill) do scene
l_theme = default_theme(scene, Lines)
Attributes(
color=l_theme.color,
colormap=l_theme.colormap,
colorrange=get(l_theme.attributes, :colorrange, automatic),
linestyle=l_theme.linestyle,
linewidth=l_theme.linewidth,
fillalpha=0.15,
lower=automatic,
upper=automatic,
)
end
function Makie.plot!(p::LinesFill)
lines!(p, p[1:2]...;
color = p.color,
linestyle = p.linestyle,
linewidth = p.linewidth,
colormap = p.colormap,
colorrange = p.colorrange,
)
lower = lift(p[:lower], p[2]) do lower, y
return lower === automatic ? zero(y) : lower
end
upper = lift(p[:upper], p[2]) do upper, y
return upper === automatic ? y : upper
end
meshcolor = lift(to_color∘tuple, p.color, p.fillalpha)
band!(p, p[1], lower, upper; color = meshcolor)
end