# Vegalite.jl: levels and DataFrames

**URL:** <https://discourse.julialang.org/t/vegalite-jl-levels-and-dataframes/35638>\
**Category:** Visualization\
**Created:** [March 6, 2020, 12:52pm UTC](https://discourse.julialang.org/t/vegalite-jl-levels-and-dataframes/35638 "2020-03-06T12:52:53Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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:** [March 6, 2020, 2:50pm UTC](https://discourse.julialang.org/t/vegalite-jl-levels-and-dataframes/35638/7 "2020-03-06T14:50:26Z")

</div>

I think it can be done, but supposing that it should be done automagically is wrong (for now), at least in my opinion. Typically I dislike automatisms like this, I prefer that I have to be explicit with the things I want to have in a plot and how it should be. But for VegaLite.jl this is not me who has to decide.

Despite that, the categorial values can be used just like normal columns in the DataFrame:

```julia
using VegaLite, DataFrames, CategoricalArrays

data = DataFrame(
    a=["A","B","C","D","E","F","G","H","I"],
    b=[28,55,43,91,81,53,19,87,52],
    c=["C1","C1","C2","C2","C1","C1","C2","C2","C2"]
)

categorical!(data, :c)

data |> @vlplot(
	:bar, 
	x="a:o", 
	y=:b,
	color=:c
)

```

The bar chart you are heading for seems to be the grouped bar chart as in your other (older) thread

> [@Vegalite.jl; simple grouped bar chart](https://discourse.julialang.org/t/vegalite-jl-simple-grouped-bar-chart/32702):
>
> I’ve been fighting with this occasionally, and haven’t gotten it to work. I want to make a simple grouped bar chart out of a simple DataFrame, but no example I’ve seen that just quickly gets to the point. Suppose it’s a simple one, having a few columns like Year, AmountOfPeople and AmountOfPeopleCasualty. You want to simply plot a bar chart where x has the year, and y has both the amount of people and the amount of casualties (out of these people), where these two columns are immediately next t…

---

_[View the full topic](https://discourse.julialang.org/t/vegalite-jl-levels-and-dataframes/35638)._
