我想出了如何使用包“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)
(这在 this question 中有描述。)
现在我想使用“Plots”包的 plot
函数来做同样的事情。有选项 ribbon
和 fillrange
(参见 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)
ribbon 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
关于plot - 使用 Julia-Package "Plots"的不对称带状折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37701317/