I'm trying to plot multiple layers in Gadfly plot with a pattern as following:
p=plot(yintercept=[0,1,2,3],Geom.hline(color=colorant"darkgray", size=0pt),
[ layer( x=locs, y=BS[:,i]+1-1, Geom.line,Theme(default_color=colorant"red") ) for i in ind[1] ] ... ,
[ layer( x=locs, y=BS[:,i]+2-1, Geom.line,Theme(default_color=colorant"red") ) for i in ind[2] ] ... ,
[ layer( x=locs, y=BS[:,i]+3-1, Geom.line,Theme(default_color=colorant"red") ) for i in ind[3] ] ... ,
[ layer( x=locs, y=BS[:,i]+4-1, Geom.line,Theme(default_color=colorant"red") ) for i in ind[4] ] ...
)
It's quite annoying to add layers manually when m getting large(currently m is up to 4). So I want to write a loop to add layers to current plot p.
p=plot(yintercept=[0,1,2,3],Geom.hline(color=colorant"darkgray", size=0pt) )
for m=0:M
q = append!(p.layers, [ layer( x=locs, y=BS[:,i]+m, Geom.line,Theme(default_color=colorant"red") ) for i in ind[m+1] ] ... )
end
The loop doesn't work now. Any ideas on how to easily get the layers added?