library(ggplot2)
library(gridExtra)
df1 <- data.frame(x=c("A1","A2","A3","A4"),something=c(10,18,24,32))
df2 <- data.frame(x=c("C1","C2","C3","C4"),somethingelse=c(10543,182334,242334,32255))
p1 <- ggplot(df1,aes(x,something))+
geom_bar(stat="identity")
p2 <- ggplot(df2,aes(x,somethingelse))+
geom_bar(stat="identity")
png("test.png",height=8,width=6,res=120,units="cm")
gridExtra::grid.arrange(p1,p2,heights=grid::unit(c(4,4),"cm"))
dev.off()
When I manually combine two or more plots like above, how can I fix the y-axis widths to be the same, so that my bars across all plots (A1-C1,A2-C2,..) align? Is there some way to calculate max y label width and apply that width to the y-axis of all plots? And no, facets are not something I want in this particular case.