# How to adjust the position of each bar in Geom.bar(GadFly)

**URL:** https://discourse.julialang.org/t/how-to-adjust-the-position-of-each-bar-in-geom-bar-gadfly/12536
**Category:** General Usage
**Created:** [July 20, 2018, 1:40pm UTC](https://discourse.julialang.org/t/how-to-adjust-the-position-of-each-bar-in-geom-bar-gadfly/12536 "2018-07-20T13:40:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jayce\_ram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayce_ram/32/3977_2.png) [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)
#### Post date: [July 20, 2018, 1:40pm UTC](https://discourse.julialang.org/t/how-to-adjust-the-position-of-each-bar-in-geom-bar-gadfly/12536/1 "2018-07-20T13:40:20Z")

</div>

For design matter, I would like that axe-x of the plot bellow showed only 2018 and 2019 (and not 2017.5 etc).  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/b/7ba2814c012b4219cfeb80fc00f431279c27ae50.png)

I have converted the column related to the year in string and I have succeed to get my goal but I was wondering if there is another way to get the same result. The dataframes I really will have to deal representing variables of a LP problem and it will not be practical at all spend time to convert all the columns in string. Thanks in advance.

```julia
using DataFrames,Gadfly 

df = DataFrame(
  product = ["prodA","prodB","prodC","prodA","prodB","prodC"],
  year = [2018,2018,2018,2019,2019,2019],
  prod = [120,150,170,160,100,130],  
)

sort!(df,cols=[:year])
plot(df, x="year", y="prod",color="product", Geom.bar)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/3/6/363c63b534ed4a660a0faf721845f6ab09ef72cd.png)

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [July 20, 2018, 11:21pm UTC](https://discourse.julialang.org/t/how-to-adjust-the-position-of-each-bar-in-geom-bar-gadfly/12536/2 "2018-07-20T23:21:10Z")

</div>

Does this work for you?:

```julia
p = plot(df, x=:year, y=:prod, color=:product, Geom.bar, Scale.x_discrete)

```

---

<div class="post-metadata">

### Author: ![jayce\_ram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayce_ram/32/3977_2.png) [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)
#### Post date: [July 23, 2018, 12:42pm UTC](https://discourse.julialang.org/t/how-to-adjust-the-position-of-each-bar-in-geom-bar-gadfly/12536/3 "2018-07-23T12:42:53Z")

</div>

Thanks!It worked fine.
