# Stacked bar graphs

**URL:** https://discourse.julialang.org/t/stacked-bar-graphs/18550
**Category:** Visualization
**Tags:** statsplots, vegalite
**Created:** [December 11, 2018, 9:08am UTC](https://discourse.julialang.org/t/stacked-bar-graphs/18550 "2018-12-11T09:08:29Z")
**Posts on this page:** 1
**Showing post:** 22

<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: [January 3, 2019, 6:10pm UTC](https://discourse.julialang.org/t/stacked-bar-graphs/18550/22 "2019-01-03T18:10:55Z")

</div>

> [@svpillai](#):
>
> how do I delete titles for the axes? i.e. I want to delete the titles “Model”, “VarianceDecomposition”, and the “Variance” that appears at the bottom four times.

Like this:

```julia
df |>
  @vlplot(:bar,
    x={:Sex, title=nothing},
    y={:Freq, title=nothing}, 
    color={:Eye, title=nothing}, 
    column={:Hair, title=nothing}
  )

```

The trick is that you now pass a composite value in curly brackets `{}` to `x` etc., and then you can configure more details there. All the config options for axis title are described [here](https://vega.github.io/vega-lite/docs/axis.html#title).

> [@svpillai](#):
>
> All my numbers are supposed to add up to 100 (which they do), however for the Log I graph, I see a white space on top of the 100 that needs to be deleted. This whitespace doesn’t appear in some other graphs such as the one for log Y which contain similar datasets, so it seems a bit arbitrary. Is there a way to delete this? I’m not sure why it’s appearing for only some graphs since I have copy-pasted the same code.

I think you need to configure your scales a bit for that. It might be enough to configure the scale to not try to come up with nice numbers on the axis like this (documented [here](https://vega.github.io/vega-lite/docs/scale.html#continuous)):

```julia
 df |>
  @vlplot(:bar, x=:Sex, y={:Freq, scale={nice=false}}, color=:Eye, column=:Hair)

```

But you might also have to additionally configure your [domain](https://vega.github.io/vega-lite/docs/scale.html#domain):

```julia
 df |>
  @vlplot(:bar,
    x=:Sex,
    y={:Freq, scale={domain=[0,100], nice=false}},
    color=:Eye, column=:haircut_woman
  )

```

I’m not entirely sure why this doesn’t work automatically. I suspect, that maybe there is a small numerical rounding error that pushes some value just slightly above 100, and then vega-lite thinks it needs to extend the axis or something like that…

> [@svpillai](#):
>
> How do I change the ordering of the variables? for example, I want models to be ordered as HANK, RANK, TANK, BUNK. And the stacks (shocks) need rearranging as well. I couldn’t find documentation on this.

You can specify a sort property for the encoding, documented [here](https://vega.github.io/vega-lite/docs/sort.html#sort-array):

```julia
 df |>
  @vlplot(:bar,
    x=:Sex,
    y=:Freq,
    color=:Eye,
    column={:haircut_woman, sort=["Red", "Blond", "Brown", "Black"]}
  )
```

---

_[View the full topic](https://discourse.julialang.org/t/stacked-bar-graphs/18550)._
