gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 01:39:51 25 4
gpt4 key购买 nike

这是我正在寻找的示例:

example proportion plot

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

最佳答案

这里有一个方法:

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

enter image description here

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

关于julia - 如何在 Julia 中绘制 'proportion graph'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71794565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com