Reputation: 1081
Here is an example of what I am looking for:
I've looked at all of the examples in the documentation and could not find a similar graph. Any help would be appreciated.
Upvotes: 2
Views: 217
Reputation: 3005
Following @sanidhya-singh's link also gives a built-in solution:
julia> areaplot(1:3, [1 2 3; 7 8 9; 4 5 6], seriescolor = [:red :green :blue], fillalpha = [0.2 0.3 0.4])
which gives
Maybe worth adding to the docs though!
[EDIT] This example has been added to the Plots.jl docs
Upvotes: 2
Reputation: 521
Here's a way:
using Plots
@userplot StackedArea
# a simple "recipe" for Plots.jl to get stacked area plots
# usage: stackedarea(xvector, datamatrix, plotsoptions)
@recipe function f(pc::StackedArea)
x, y = pc.args
n = length(x)
y = cumsum(y, dims=2)
seriestype := :shape
# create a filled polygon for each item
for c=1:size(y,2)
sx = vcat(x, reverse(x))
sy = vcat(y[:,c], c==1 ? zeros(n) : reverse(y[:,c-1]))
@series (sx, sy)
end
end
a = [1,1,1,1.5,2,3]
b = [0.5,0.6,0.4,0.3,0.3,0.2]
c = [2,1.8,2.2,3.3,2.5,1.8]
sNames = ["a","b","c"]
source: https://discourse.julialang.org/t/how-to-plot-a-simple-stacked-area-chart/21351/2
Upvotes: 4