2016-06-08 83 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。 –