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

ese*_*sel 3 plot julia gadfly plots.jl

我想出了如何使用包“Gadfly”和以下代码绘制带有不对称“丝带”的折线图

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)
Run Code Online (Sandbox Code Playgroud)

(这是在这个问题中描述的 。)

在此处输入图片说明

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

小智 5

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

Pkg.checkout("Plots")
Pkg.checkout("RecipesBase")
Run Code Online (Sandbox Code Playgroud)

现在要重现您的示例,您可以执行以下操作:

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

血小板

功能区 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
Run Code Online (Sandbox Code Playgroud)