I figured out how to plot a line graph with an asymmetric "ribbon" around it with the package "Gadfly" and the following code
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 was described in this question.)
Now i would like to do the same using the plot
function of the "Plots" package. There are options ribbon
and fillrange
(see http://plots.readthedocs.io/en/latest/examples/pyplot/#layouts-margins-label-rotation-title-location) but I could not figure out how to use them. Is it possible to create such a plot using the "Plots" package and if yes, how?
Until I tag a new version of RecipesBase and Plots, you'll need to:
Pkg.checkout("Plots")
Pkg.checkout("RecipesBase")
Now to reproduce your example, you could do:
using Plots; pyplot(border=false)
x = -10:10
y = x .^ 2
plot(x, y, ribbon=(5,10), fillalpha=0.2)
The ribbon arg could take many forms:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With