VegaLite.jl equivalent of `facet_wrap`?

is there a way to wrap around the panels of multiple plots (similar to `facet_wrap in ggplot2)? For example would it be possible to arrange the Anscombe’s quartet plot shown in the docs (http://fredo-dedup.github.io/VegaLite.jl/stable/examples/examples_faceting/) in two rows and two columns?

I tried the following (trying to adapt the syntax from Becker’s Barley Trellis Plot | Vega-Lite) but it doesn’t work:

using VegaLite, VegaDatasets
anscombe = dataset("anscombe")
p = anscombe |> @vlplot(mark="point",
                      columns=2,
                      encoding={
                      facet={field="Series", typ="nominal"},
                      x={:X, scale={zero=false}},
                      y={:Y, scale={zero=false}},
                      }
                      ) 

This is coming in the next version of Vega-lite, which I believe is getting close to being released. We’ll then need to update VegaLite.jl to target it, but I don’t expect that to be too much work.

thanks, good to know this feature is being implemented

Hi @davidanthoff
Has there been an update on this? I have

spec = dfms |>
@vlplot(
    facet={field="cov", typ="nominal", columns=2}
) + 
@vlplot(   
    x = {:yr, typ="quantitative"},
    y = {:value, typ="quantitative"},
    color="variable:n",
    height=400,
    width=400,    
    mark={
        :line,
        point=true
    }
)

but dosn’t seem to work.

Take a look at this example. Essentially we have a wrap encoding channel now. So something like @vlplot(..., wrap="cov:n", columns=2) should do the trick.

Another minor point: No need to do typ anymore, you can just use type, that was solved once we moved to Julia 1.0. And on master there also shouldn’t be a need to specify the type at all, I think it should auto-detect that things are quant.

1 Like