如何在 Julia 中绘制 'proportion graph'?

How to draw a 'proportion graph' in Julia?

这是我正在寻找的示例:

我查看了文档中的所有示例,但找不到类似的图表。任何帮助将不胜感激。

这里有一个方法:

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"]

来源:https://discourse.julialang.org/t/how-to-plot-a-simple-stacked-area-chart/21351/2

跟随@sanidhya-singh的link也给出了一个built-in解决方案:

julia> areaplot(1:3, [1 2 3; 7 8 9; 4 5 6], seriescolor = [:red :green :blue], fillalpha = [0.2 0.3 0.4])

给出

也许值得添加到文档中!


[EDIT] 此示例已添加到 Plots.jl docs