Merge pull request #2090 from daschw/areaplot
add areaplot recipe (close #1423)
This commit is contained in:
commit
64e035c53c
@ -1,7 +1,7 @@
|
|||||||
name = "Plots"
|
name = "Plots"
|
||||||
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||||
author = ["Tom Breloff (@tbreloff)"]
|
author = ["Tom Breloff (@tbreloff)"]
|
||||||
version = "0.25.2"
|
version = "0.25.3"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||||
|
|||||||
@ -1183,3 +1183,27 @@ end
|
|||||||
@series Plots.isvertical(plotattributes) ? (sx, sy) : (sy, sx)
|
@series Plots.isvertical(plotattributes) ? (sx, sy) : (sy, sx)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
"""
|
||||||
|
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])
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
@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
|
||||||
|
for i in 1:size(data, 2)
|
||||||
|
@series begin
|
||||||
|
fillrange := i > 1 ? data[:,i-1] : 0
|
||||||
|
x, data[:,i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user