# Group as variable in statsplots

**URL:** <https://discourse.julialang.org/t/group-as-variable-in-statsplots/24352>\
**Category:** General Usage\
**Created:** [May 18, 2019, 12:58pm UTC](https://discourse.julialang.org/t/group-as-variable-in-statsplots/24352 "2019-05-18T12:58:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [May 18, 2019, 12:58pm UTC](https://discourse.julialang.org/t/group-as-variable-in-statsplots/24352/1 "2019-05-18T12:58:15Z")

</div>

Hi-

I would like to pass a variable to the keyword group in `StatsPlots`, but I receive an error. Here is a simple example:

```julia
using DataFrames,StatsPlots
df = DataFrame(a=rand(100),b=rand(100),c=rand(1:2,100),d=rand(1:2,100))
group = (:c,:d)
for c in (:a,:b)
    p = @df df histogram(cols(c),group=cols(group),layout=(2,2))
    display(p)
end

```

Error:

```julia

MethodError: no method matching extractGroupArgs(::Array{Int64,2}, ::Array{Float64,1})
Closest candidates are:
  extractGroupArgs(!Matched::AbstractArray{T,1} where T, ::Any...; legendEntry) at /home/dfish/.julia/packages/Plots/oiirH/src/args.jl:1078
  extractGroupArgs(!Matched::Tuple, ::Any...) at /home/dfish/.julia/packages/Plots/oiirH/src/args.jl:1091
  extractGroupArgs(!Matched::NamedTuple, ::Any...) at /home/dfish/.julia/packages/Plots/oiirH/src/args.jl:1101

```

I also tried` group=group` and `group = cols.(group)` without success.
