# Bar chart with rotated x label for each bar

**URL:** <https://discourse.julialang.org/t/bar-chart-with-rotated-x-label-for-each-bar/28554>\
**Category:** Visualization\
**Created:** [September 9, 2019, 11:58am UTC](https://discourse.julialang.org/t/bar-chart-with-rotated-x-label-for-each-bar/28554 "2019-09-09T11:58:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [September 9, 2019, 12:29pm UTC](https://discourse.julialang.org/t/bar-chart-with-rotated-x-label-for-each-bar/28554/2 "2019-09-09T12:29:14Z")

</div>

Try setting xticks manually. I think something like `xticks=minimum(df.naics):maximum(df.naics)` (assuming that’s the column that provides the x values. Compare:

```julia
julia> df = DataFrame(idx=1:20, val = rand(20), label = [randstring(4) for _ in 1:20]);

julia> bar(df.idx, df.val)

julia> bar(df.idx, df.val, legend=false)

```

 ![50%20AM](https://global.discourse-cdn.com/julialang/original/3X/5/b/5b0f67fb72f75f3c73b146d5493ccee09181fb8c.jpeg)

to

```julia
bar(df.idx, df.val, legend=false, xticks=1:20)

```

 ![48%20AM](https://global.discourse-cdn.com/julialang/original/3X/d/2/d2d31aad720628a27c4b2b3a2aabaeb9bd7eadde.jpeg)

You can also set the labels to be strings:

```julia
bar(df.idx, df.val, legend=false, xticks=(1:20, df.label), xrotation=90)

```

 ![45%20AM](https://global.discourse-cdn.com/julialang/original/3X/9/3/937655a5a23c87b47c35beeba83101eb8ef726d8.jpeg)

As for centering text, I’m guessing it’s something with `xfontvalign` or `xfonthalign`, but I can’t figure it out. And for removing the spaces, take a look at the various `framestyle`s, and I think there are arguments involving margins, but I don’t know for sure. See the bottom of [this page](http://docs.juliaplots.org/latest/examples/gr/#portfolio-composition-maps) for all the attributes you can play with.

Would be nice if the possible arguments for all of those attributes lived somewhere in the docs too.

---

_[View the full topic](https://discourse.julialang.org/t/bar-chart-with-rotated-x-label-for-each-bar/28554)._
