# When are round brackets required for VegaLite?

**URL:** <https://discourse.julialang.org/t/when-are-round-brackets-required-for-vegalite/32401>\
**Category:** Visualization\
**Created:** [December 17, 2019, 7:35pm UTC](https://discourse.julialang.org/t/when-are-round-brackets-required-for-vegalite/32401 "2019-12-17T19:35:47Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [December 17, 2019, 7:35pm UTC](https://discourse.julialang.org/t/when-are-round-brackets-required-for-vegalite/32401/1 "2019-12-17T19:35:47Z")

</div>

In this example, why are the brackets `(` and `)` needed to surround the extra `@vlplot` commands?

```julia
using VegaDatasets
dataset("weather.csv") |>
@vlplot(repeat={column=[:temp_max,:precipitation,:wind]}) +
(
    @vlplot() +
    @vlplot(
        :line,
        y={field={repeat=:column},aggregate=:mean,typ=:quantitative},
        x="month(date):o",
        detail="year(date):t",
        color=:location,
        opacity={value=0.2}
    ) +
    @vlplot(
        :line,
        y={field={repeat=:column},aggregate=:mean,typ=:quantitative},
        x="month(date):o",
        color=:location
    )
)

```

Removing them only plots the last `@vlplot` so I am guessing that the brackets somehow “keep them together”?

---

<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:** [December 17, 2019, 7:45pm UTC](https://discourse.julialang.org/t/when-are-round-brackets-required-for-vegalite/32401/2 "2019-12-17T19:45:36Z")

</div>

The expression in the `()` creates a layered spec, and then you want to have that as the spec that gets faceted/repeated. So in general the rule is that if you have a facet/repeat element, you can only add _one_ spec via `+` as the child spec there.

I’m still not super happy with the rules for this whole composition of plots, I have to admit. They work once one has figured them out, but I’m still wondering whether we could come up with a better story…

Also, I really need to write documentation for that stuff 🙂

---

<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:** [December 17, 2019, 7:52pm UTC](https://discourse.julialang.org/t/when-are-round-brackets-required-for-vegalite/32401/3 "2019-12-17T19:52:47Z")

</div>

Ahh I see, so

```julia
@vlplot(repeat={column=[:temp_max,:precipitation,:wind]}) +
(
… anything in here goes in a 'spec' and I can add child vlplots in here
)
```

---

<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:** [December 17, 2019, 8:07pm UTC](https://discourse.julialang.org/t/when-are-round-brackets-required-for-vegalite/32401/4 "2019-12-17T20:07:23Z")

</div>

Yes, exactly. Inside the parenthesis you can for example create a layered plot, or whatever you want.
