I am asking this question which sounds exactly like this post because it did not solve the problem. Here is my question. I have 2 plots that I want to put together with their scale perfectly in line. Here is what I got to :
As you can see the x axis is not exactly in line. Here is the code I used
bp_horiz<-ggplot(df,aes(y=Corg_rate))+
geom_boxplot()+
theme_classic()+
labs(y="Corg annual rate")+
coord_flip()
histo<-ggplot(data=df, aes(Corg_rate))+
geom_histogram(fill="grey",col="black")+
labs(x="Corg annual rate",y="Counts")+
theme_classic()+
labs(x=NULL,y="Counts")
plot_grid(histo,boxplot_horiz,ncol=1,align="v",rel_heights=c(4,1),axis = 'lr')
I tried to change the align parameters from v to h to hv without success. I tried using egg with the same problem on non alignment. I tried using ggMarginal but it does not work when the center plot is a histogram.
How would you solve this issue?
I do't know how to add data but to make things clearer here is the beginning of it:
Corg_rate
1 -0.0147
2 0.0106
3 0.114
4 -0.00230
5 0.0105
6 -0.0574
7 0.0102
8 -0.00472
9 0.0335
10 -0.00803