How to adjust the position of each bar in

For design matter, I would like that axe-x of the plot bellow showed only 2018 and 2019 (and not 2017.5 etc).

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.

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],  

plot(df, x="year", y="prod",color="product",


Does this work for you?:

p = plot(df, x=:year, y=:prod, color=:product,, Scale.x_discrete)
1 Like

Thanks!It worked fine.