Hi all!
I’m trying to make a stacked plot from the Data Below
when I plot using the regular plot function, i got the correct values/positions, but i need then stacked. Using areaplot instead of plot is not working as expected.
Anyone could tell what I’m doing wrong???
Thanks in advance!!!
For stacked area plots, I think we need multiple y-series to be plotted against a common x-axis support. Each series is a column of the y-matrix and should have same length as the support vector x.
Maybe i wasnt clear about what i was trying to do. I would like a plot more like the one in link bellow from julia plot documentation, stacked. The shaded area are a great visual but not needed here.
For example, at x = 3 red curve has value 7 and the green one has value 8, it should be 15 in the graphic 7(red) + 8(green). At x = 4, the plot should back to 8 value as red function “has ended” but green is still on.
I could recreate this 3 curves with shared/sync x axis but it will cost memory allocation. The original data had lenght of 288, for each curve. Then i found the attribute “seriestype = :steppost” and it lowered from 288 to 4. The end application should be embedded somewhere, so less memory less final cost. https://docs.juliaplots.org/latest/gallery/gr/generated/gr-ref058/#gr_ref058
Nice example! I could figure out how to do the right stack plot. Didn’t have to use Interpolations.jl at all, and final result (x0, y0) are smaller than original problem.
Final code:
x = [0 0 0; 1 3 5; 4 8 7; 10 10 10]
y = [7 8 9]
x0 = sort(unique(x))
y0 = zeros(length(x0), length(y))
for j in eachindex(y)
for i in eachindex(x0)
if x0[i] ≥ x[2,j] && x0[i] < x[3,j]
y0[i,j] = y[j]
end
end
end
p =areaplot(x0, y0, fa=0.3, st=:steppost, seriescolor = [:red :green :blue])
display("image/png", p)