# StatsPlots @df macro with args/kwargs

**URL:** <https://discourse.julialang.org/t/statsplots-df-macro-with-args-kwargs/22419>\
**Category:** Visualization\
**Created:** [March 27, 2019, 5:03pm UTC](https://discourse.julialang.org/t/statsplots-df-macro-with-args-kwargs/22419 "2019-03-27T17:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gajomi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gajomi/32/7655_2.png) [@gajomi](https://discourse.julialang.org/u/gajomi)\
**Post date:** [March 27, 2019, 5:03pm UTC](https://discourse.julialang.org/t/statsplots-df-macro-with-args-kwargs/22419/1 "2019-03-27T17:03:55Z")

</div>

I can make the following call in StatsPlots using the `@df` macro:

```julia
@df labs histogram(:obs_value, group = :observation, legend = :topright, size = (1500,300))

```

However, when I try

```julia
foo = :observation
baz = :obs_value
@df labs histogram(baz, group = foo, legend = :topright, size = (1500,300))

```

I get

```julia
MethodError: no method matching extractGroupArgs(::Symbol, ::Symbol)

```

back from the repl (presumably because the macro isn’t/can’t interpolate the values in the variables at runtime?). Is there a way to get this sort of behavior using the macro? Or does this need to be done with functions?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [March 27, 2019, 7:01pm UTC](https://discourse.julialang.org/t/statsplots-df-macro-with-args-kwargs/22419/2 "2019-03-27T19:01:32Z")

</div>

Wrap with `cols`, e.g. `@df df plot(cols(baz),... `

---

<div class="post-metadata">

**Author:** ![gajomi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gajomi/32/7655_2.png) [@gajomi](https://discourse.julialang.org/u/gajomi)\
**Post date:** [March 27, 2019, 8:11pm UTC](https://discourse.julialang.org/t/statsplots-df-macro-with-args-kwargs/22419/3 "2019-03-27T20:11:02Z")

</div>

Works like a charm. I blasted right through that section of the StatsPlots README. Thanks!
