Change spacing between xticks


I would like to stack a bar plot and a box plot and have their boxes align. But I can’t find a way to do this. Here’s a MWE :

using DataFrames, StatsPlots, StatsBase
df = DataFrame(a = rand(1:6, 30), b = rand(30))
p = boxplot(df.a, df.b)
cm = countmap(df.a)
f = bar(cm)

fp = plot(f,p, layout = grid(2,1, heights = (0.2,0.8)))

Which gives this


The central bars are more or less aligned but you can see that 1 and 6 are offset.

Thank you !

using f = bar(cm, widen = false) worked

1 Like

I wonder why widen is false for boxplots :thinking:

Yes defaults seem to change from one recipe to another…