使用 Julia-Package 的不对称带状折线图 "Plots"

Line graph with asymmetric ribbon using Julia-Package "Plots"

我想出了如何使用包 "Gadfly" 和以下代码

绘制带有不对称 "ribbon" 的折线图
x=collect(-10:10);
y=[i^2 for i in -10:10];
ymin = y-5;
ymax = y+10;
using Gadfly
plot(x=x, y=y, ymin=ymin, ymax=ymax, Geom.smooth, Geom.ribbon)

(这在 this question 中有描述。)

现在我想使用 "Plots" 包的 plot 函数来做同样的事情。有 ribbonfillrange 选项(请参阅 http://plots.readthedocs.io/en/latest/examples/pyplot/#layouts-margins-label-rotation-title-location),但我不知道如何使用它们。是否可以使用 "Plots" 包创建这样的图,如果可以,如何创建?

在我标记 RecipesBase 和 Plots 的新版本之前,您需要:

Pkg.checkout("Plots")
Pkg.checkout("RecipesBase")

现在要重现您的示例,您可以这样做:

using Plots; pyplot(border=false)
x = -10:10
y = x .^ 2
plot(x, y, ribbon=(5,10), fillalpha=0.2)

功能区 arg 可以采用多种形式:

plot(x, y, ribbon = 5)  # both sides are 5
plot(x, y, ribbon = 1:3) # both sides cycle through 1:3
plot(x, y, ribbon = (5, 1:3))  # bottom is 5, top cycles 1:3