Reputation: 11
I tried to create a @recipe
Stackplot in Julia Makie. This is my first attempt:
@recipe(MyPlot, x, y, z) do scene
Theme(
plot_color = :red
)
end
function Makie.plot!(myplot::MyPlot)
map(myplot[:x], myplot[:y]) do xs, ys
cys= []
for i in 1:length(ys)
push!(cys,cumsum(ys[1:i])[end])
end
for (x, y) in zip(xs, cys)
scatterlines!(myplot, x, y)
band!(myplot, x, zero(y), y, color = (:red, 0.3))
end
end
myplot
end
myplot([[1, 2, 3], [1, 2, 3]], [[1, 2, 3], [1, 2, 7]])
The problem is I would like to create an area that starts at 0 and ends at y_1, another area that starts at y_1 and ends at y_2, and so on until y_n. Additionally, I would like to change the color so that the scatterlines are linked to the color of the area below it.
I tried playing with :color
, but the problem is that every scatterline!
and every band!
has the same color.
Upvotes: 1
Views: 93