2016-06-08 37 views
2

我想出如何绘制的线图具有不对称“带”绕其与包“牛虻”,“图解”不对称带和下面的代码线图使用朱莉娅 - 套餐

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被描述。)

enter image description here

现在我想用“自留地”包的plot功能做同样的。有选项ribbonfillrange(见http://plots.readthedocs.io/en/latest/examples/pyplot/#layouts-margins-label-rotation-title-location),但我无法弄清楚如何使用它们。是否有可能使用“Plots”软件包创建这样的情节,如果是的话,如何?

回答

2

直到我标记RecipesBase和情节的一个新版本,你需要:

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) 

plt

色带参数可以有多种形式:

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 
+0

我用'Pkg.checkout'试过了。使用GR,我得到:“MethodError:convert没有方法匹配convert(:: Type {Float64},:: Array {Float64,1})”,“gadfly()”产生一个弃用警告。同样用'plotly()'它不起作用(“fillrange ignored”)。如果它只适用于PyPlot,那么“Plots”包现在不是我的正确选择。但无论如何,非常感谢您的回复。 – esel

+0

这目前与pyplot和gr后端一起使用,不需要Pkg.checkout。 –