# Trouble plotting grouped data (VegaLite.jl)

**URL:** https://discourse.julialang.org/t/trouble-plotting-grouped-data-vegalite-jl/42874
**Category:** Visualization
**Created:** [July 10, 2020, 9:34pm UTC](https://discourse.julialang.org/t/trouble-plotting-grouped-data-vegalite-jl/42874 "2020-07-10T21:34:26Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [July 11, 2020, 3:37pm UTC](https://discourse.julialang.org/t/trouble-plotting-grouped-data-vegalite-jl/42874/2 "2020-07-11T15:37:24Z")

</div>

The problem is the type “Any” of your categorial columns :Company and :Gear.  
Please try

```julia
gearavg[!,:Company] = convert(Array{String,1},gearavg[!,:Company])
gearavg[!,:Gear] = convert(Array{String,1},gearavg[!,:Gear])
gearavg |> @vlplot(:bar, x = :Gear, y = :OverallMean, color = :Gear, encoding = {facet = {field = :Company, columns = 2}}, height = 500, width = 500)

```

The ` |> display` at the end is not needed.

For future questions you should provide Copy&Paste code. This makes it much easier to help. Your DataFrame isn’t copy&paste code, so it needs some coding to reproduce your issue. See:

```julia
using DataFrames, VegaLite

companies=["Davey","Mario's","Arbor Works","MLU Willhelm","Asplundh","Wright Tree Service","Mowbray’s Tree Service"]
gears=["Hitch-Climber Pulley","Other","Split Tail","Taut Line","SRT"]

drop=trues(35)
drop[[4,6,15,23,30] ] .= false

gearavg= DataFrame( Company= convert(Array{Any,1},[x[2] for x in vec(collect(Iterators.product(gears,companies))) ][drop]) )
gearavg[!,:Gear]= convert(Array{Any,1},[x[1] for x in vec(collect(Iterators.product(gears,companies))) ][drop])
gearavg[!,:OverallMean]= convert(Array{Any,1},(100 .* rand(Float64,size(gearavg)[1])))

gearavg |> @vlplot(:bar, x = :Gear, y = :OverallMean, color = :Gear, encoding = {facet = {field = :Company, columns = 2}}, height = 50, width = 50)

gearavg[!,:Company] = convert(Array{String,1},gearavg[!,:Company])
gearavg[!,:Gear] = convert(Array{String,1},gearavg[!,:Gear])

gearavg |> @vlplot(:bar, x = :Gear, y = :OverallMean, color = :Gear, encoding = {facet = {field = :Company, columns = 2}}, height = 50, width = 50)

```

This is just hacked together to make your issue appear in my REPL.  
Therefore consider

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

_[View the full topic](https://discourse.julialang.org/t/trouble-plotting-grouped-data-vegalite-jl/42874)._
