# VegaLite.jl equivalent of \`facet\_wrap\`?

**URL:** https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961
**Category:** Visualization
**Tags:** plotting
**Created:** [March 17, 2019, 12:35pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961 "2019-03-17T12:35:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![sam81](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sam81/32/1736_2.png) [@sam81](https://discourse.julialang.org/u/sam81)
#### Post date: [March 17, 2019, 12:35pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961/1 "2019-03-17T12:35:16Z")

</div>

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/](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](https://vega.github.io/vega-lite/examples/trellis_barley.html)) but it doesn’t work:

```julia
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}},
                      }
                      ) 

```

---

<div class="post-metadata">

### Author: ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)
#### Post date: [March 17, 2019, 3:11pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961/2 "2019-03-17T15:11:26Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sam81](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sam81/32/1736_2.png) [@sam81](https://discourse.julialang.org/u/sam81)
#### Post date: [March 17, 2019, 3:26pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961/3 "2019-03-17T15:26:16Z")

</div>

thanks, good to know this feature is being implemented

---

<div class="post-metadata">

### Author: ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)
#### Post date: [January 14, 2020, 8:28pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961/4 "2020-01-14T20:28:17Z")

</div>

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

```julia
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.

---

<div class="post-metadata">

### Author: ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)
#### Post date: [January 14, 2020, 8:37pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961/5 "2020-01-14T20:37:43Z")

</div>

Take a look at [this example](https://www.queryverse.org/VegaLite.jl/stable/examples/examples_faceting/#Trellis-Scatter-Plot-1). 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.

---

<div class="post-metadata">

### Author: ![s-baumann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/s-baumann/32/5843_2.png) [@s-baumann](https://discourse.julialang.org/u/s-baumann)
#### Post date: [December 23, 2024, 12:37pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961/6 "2024-12-23T12:37:43Z")

</div>

Is there a way to specify that the scales should be “free” rather than “fixed” (in ggplot2 language)?

---

<div class="post-metadata">

### Author: ![s-baumann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/s-baumann/32/5843_2.png) [@s-baumann](https://discourse.julialang.org/u/s-baumann)
#### Post date: [December 23, 2024, 12:46pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961/7 "2024-12-23T12:46:38Z")

</div>

Found it! This is how:

```julia
df |> VegaLite.@vlplot(
    title = "A Chart",
    :line,
    x={field="time"},
    y={field="pnl", axis={title="PnL"}},
    color= {field="strattegy"},
    width=width,
    height=height,
    wrap= {field="group_of_dates", type="ordinal"},
    resolve={scale={x="independent"}}
)

```

---

<div class="post-metadata">

### Author: ![francisbarton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/francisbarton/32/205194_2.png) [@francisbarton](https://discourse.julialang.org/u/francisbarton)
#### Post date: [October 10, 2025, 1:25pm UTC](https://discourse.julialang.org/t/vegalite-jl-equivalent-of-facet-wrap/21961/8 "2025-10-10T13:25:51Z")

</div>

Thank you - that works for me. I had been trying this, based off the VegaLite JSON documentation:  
`resolve = {axis = {x = "independent" }}`
