add areaplot recipe

This commit is contained in:
Daniel Schwabeneder 2019-07-04 11:31:00 +02:00
parent 2816b1128f
commit 8dfca61769
2 changed files with 100 additions and 69 deletions

View File

@ -1183,3 +1183,22 @@ end
@series Plots.isvertical(plotattributes) ? (sx, sy) : (sy, sx) @series Plots.isvertical(plotattributes) ? (sx, sy) : (sy, sx)
end end
end end
@userplot AreaPlot
@recipe function f(a::AreaPlot)
data = cumsum(a.args[end], dims=2)
x = length(a.args) == 1 ? (1:size(data, 1)) : a.args[1]
seriestype := :line
@series begin
fillrange := 0
x, data[:,1]
end
for i in 2:size(data, 2)
@series begin
fillrange := data[:,i-1]
x, data[:,i]
end
end
end

View File

@ -379,6 +379,18 @@ julia> curves([1,2,3,4],[1,1,2,4])
""" """
@shorthands curves @shorthands curves
"""
areaplot([x,] y)
areaplot!([x,] y)
Draw a stacked area plot of the matrix y.
# Examples
```julia-repl
julia> areaplot(1:3, [1 2 3; 7 8 9; 4 5 6], seriescolor = [:red :green :blue], fillalpha = [0.2 0.3 0.4])
```
"""
@shorthands areaplot
"Plot a pie diagram" "Plot a pie diagram"
pie(args...; kw...) = plot(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing) pie(args...; kw...) = plot(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing)
pie!(args...; kw...) = plot!(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing) pie!(args...; kw...) = plot!(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing)