Does VegaLite not support faceting of plots with errorbands? I’m struggling to make this work:
using VegaLite, DataFrames
function generatedata()
df = DataFrame()
K = 10
L = 10
Cat1 = [:A,:B]
Cat2 = [:X,:Y]
for i in Cat1, j in Cat2
tmp = DataFrame()
tmp.Cat1 = [i for _ in 1:K*L]
tmp.Cat2 = [j for _ in 1:K*L]
tmp.Week = [rem(w,K) for w in 1:K*L]
df = vcat(df,tmp)
end
df.Id = [i for i in 1:size(df,1)]
df.Value = rand(size(df,1))
df[df.Cat1.==:A,:Value] .+=1
df[df.Cat2.==:X,:Value] .-=2
return df
end
df = generatedata()
# Works (Error band + color + mean)
df |> @vlplot(x=:Week,color=:Cat2) + @vlplot(mark={:errorband, extent=:ci},y=:Value) + @vlplot(:line,y="mean(Value)")
# Facet version of this does not work:
df |> @vlplot(x=:Week,color=:Cat2,column=:Cat1) + @vlplot(mark={:errorband, extent=:ci},y=:Value) + @vlplot(:line,y="mean(Value)")
# Works (simple line version)
df |> @vlplot(:line,x=:Week,color=:Cat1,column=:Cat2,y="mean(Value)")
Brilliant! That works for me! Thanks a lot @jtackm! I also found the answer that @oheil mentioned, but wasn’t able to map it to my case last night. Thanks both of you!